View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 11:29 AM
yawnmoth
 
Posts: n/a
Default getting a list of all databases in a comma delineated format?

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 helpful. Is there any way to get the list to
output in the required format?

Reply With Quote