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!
Who is Participating?
OP_ZaharinConnect With a Mentor Commented:
take out the START and try again.
- 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).
Anthony PerkinsCommented:
Please request that the MS SQL Server zone be removed as it does not apply to your question.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

TigerBloodAuthor Commented:
@ 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.

Error message
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
TigerBloodAuthor Commented:
@ OP_Zaharin - awesome... it is working.  Huge thanks!
great! no problem tiger :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.