[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1535
  • Last Modified:

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!
0
TigerBlood
Asked:
TigerBlood
  • 3
  • 2
1 Solution
 
OP_ZaharinCommented:
- 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).
0
 
Anthony PerkinsCommented:
Please request that the MS SQL Server zone be removed as it does not apply to your question.
0
 
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
OP_ZaharinCommented:
take out the START and try again.
0
 
TigerBloodAuthor Commented:
@ OP_Zaharin - awesome... it is working.  Huge thanks!
0
 
OP_ZaharinCommented:
great! no problem tiger :)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now