mysqldump problem

Posted on 2005-04-24
Last Modified: 2012-08-14
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,

Question by:bootneck2222
    LVL 14

    Expert Comment

    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
    LVL 20

    Expert Comment

    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.

    Author Comment

    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

    LVL 1

    Accepted Solution

    PAQed with points refunded (500)

    EE Admin

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now