• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5090
  • Last Modified:

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,

Bootneck2222
0
bootneck2222
Asked:
bootneck2222
1 Solution
 
crackyCommented:
Note that --opt is on by default in MySQL 4.1:
http://dev.mysql.com/doc/mysql/en/mysqldump.html

Also, silly question, but do the tables exist?

Try it without --opt:

mysqldump -u root --password=password database_name > /apps/backup.sql
0
 
JesterTooCommented:
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.
0
 
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
pause

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

Bootneck2222
0
 
Computer101Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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