Link to home
Start Free TrialLog in
Avatar of TigerBlood
TigerBlood

asked on

How do you create a .bat file to run a MYSQLDUMP on all Databases?

I am trying to create a .bat file that will run the mysqldump.exe file and do a dump of the database to c:\mySqlDumps folder.  I can get this to work manually from the command prompt with the following:

mysqldump --all-databases  >  c:\mySqlDumps\mySQLBugDump.sql

However, I would like a .bat file for this as I plan on setting up a scheduled job to run the .bat file and have our backup software run a backup of the dump file.  The script I have in my .bat file is:

@echo off START C:\program files\mysql\mysql server 5.1\bin\mysqldump.exe --all-databases > C:\mysqldumps\mySQLBugDump.sql;

This produces the mySQLBugDump.sql file in the c:\mysqldumps directory but it is only 1KB in size (cpmpared to 30MB when I run the mysqldump command manually).

Any help resolving this would be greatly appreciated.  Thanks!
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

- spaces between filename is not recognize in DOS (command prompt). you need to wrap it with double quotes "

@echo off START "C:\program files\mysql\mysql server 5.1\bin\mysqldump.exe" --all-databases > C:\mysqldumps\mySQLBugDump.sql

- if you already have the double quotes and its still error. remove the @echo off. run the BAT file manually from command prompt to see if any errors being prompt on the screen (don't double click the BAT from windows explorer).
Avatar of Anthony Perkins
Please request that the MS SQL Server zone be removed as it does not apply to your question.
Avatar of TigerBlood
TigerBlood

ASKER

@ OP_Zaharin

I ran the command with the double quotes from the command prompt and it also produced the file but only 1KB in size.

I then removed the @echo OFF and it gave an error:

"The System cannot find the file --all-databases".  I have pasted a screenshot below of the error.

User generated image
This error is strange because when I am in the bin directory of my MySQL installation and run the command //// mysqldump --all-databases  >  c:\mySqlDumps\mySQLBugDump.sql //// from the command prompt it produces the a 30MB file containing all my database info.  There has to be a way for the.BAT file to run and produce the 30MB file with all the database info too.

@ acperkins - Sorry, I will remove from MS Sql zone
ASKER CERTIFIED SOLUTION
Avatar of OP_Zaharin
OP_Zaharin
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@ OP_Zaharin - awesome... it is working.  Huge thanks!
great! no problem tiger :)