|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm trying to write a batch file that'll backup all my databases and
had a question. I was thinking about executing SHOW Databases to get a list of all the databases and then use mysqldump on each one. To do this, I was thinking I'd use for loops as described at <http:// www.robvanderwoude.com/for.html>. The only problem is that these for loops require you use a comma / space / semicolon delineated list. Here's the command I'm using to get the list of databases: mysql -u username -ppassword --execute="SHOW Databases" Here's what it returns: +--------------------+ | Database | +--------------------+ | information_schema | | test | | whatever else | +--------------------+ That's not all that ful. Is there any way to get the list to output in the required format? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
yawnmoth wrote:
> +--------------------+ > | Database | > +--------------------+ > | information_schema | > | test | > | whatever else | > +--------------------+ > > That's not all that ful. Is there any way to get the list to > output in the required format? > You could use awk to transform the outdata to what you want it to be. There are quite many resources how to use awk. -- //Aho |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
yawnmoth wrote:
> I'm trying to write a batch file that'll backup all my databases and > had a question. I was thinking about executing SHOW Databases to get > a list of all the databases and then use mysqldump on each one. [...] What's the problem with: mysqldump --all-databases ... If you want to select a few: mysqldump -d $(mysql -NBe "show databases like '%pattern%'") Dimitre |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Nov 5, 1:55 pm, "Radoulov, Dimitre" <cichomit...@gmail.com> wrote:
> yawnmoth wrote: > > I'm trying to write a batch file that'll backup all my databases and > > had a question. I was thinking about executing SHOW Databases to get > > a list of all the databases and then use mysqldump on each one. > > [...] > > What's the problem with: > > mysqldump --all-databases ... > > If you want to select a few: > > mysqldump -d $(mysql -NBe "show databases like '%pattern%'") > > Dimitre I didn't know about that, heh. Thanks! |
|
![]() |
| Outils de la discussion | |
|
|