mysqldump problem

I am trying to create a batch file, which will dump the contents of a database into a file. I am using MySQL 4.1 on Windows. The script in the batch file, backup.bat, looks like this:

C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump -u root --password=password --opt database_name > /apps/backup.sql

When I run this batch file, a DOS window appears very quickly and disappears and the backup.sql file is created, but with nothing in it. The DOS window appears too quickly to be able to read any error messages. Is there a way of viewing the error?

I have tried running the above script directly from a DOS window. I get the following error message:

mysqldump: Got error: 1146: Table  'database_name.;' doesn't exist when doing LOCK TABLES

Any help would be very much appreciated.

Many thanks,

Who is Participating?
PAQed with points refunded (500)

EE Admin
Note that --opt is on by default in MySQL 4.1:

Also, silly question, but do the tables exist?

Try it without --opt:

mysqldump -u root --password=password database_name > /apps/backup.sql
Rather than launcing the batch file by clicking on it from Explorer, start a Command Prompt (aka DOS shell) session and then type in the name of the batch file and press enter...Unless you're using the "start" command inside your batch file, this will launch the batch process in a window that remains open until you close it allowing you to see any messages that might be generated.  In the event that it produces too much output to be contained on a single screen you can use "redirection" to capture the screen output to a file like this:   yourfile.bat  > capture.txt    then you can view capture.txt with notepad or any other text viewer.
bootneck2222Author Commented:
The error above:

mysqldump: Got error: 1146: Table  'database_name.;' doesn't exist when doing LOCK TABLES

Is caused by a ";" on the end of the script. Without it it runs fine.

When using a batch file, putting the word Pause on a line of its own i.e

C:\Program Files\MySQL\MySQL Server 4.1\bin\mysqldump -u root --password=password --opt database_name > /apps/backup.sql

will cause the DOS window to appear and stay open, thus allowing you to read any error messages. The reason the batch file was failing was because the location of the batch file was not in the path specified in the script. By default if the batch file is located in say C:\temp then a simple CD\ in the batch file will cause it to change to the script path above.

Thanks for your help anyway

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.