Easy fix for “the right syntax to use near ‘Usage: mysqldump”

Posted by James Sims

February 29, 2012

Recently when I was moving a database from one server to another I did the usual mysql dump from command line, then tried to import it on the new server, but what’s this? An error:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] –databa’ at line 1

To fix this, simply open the sql file in a text editor and remove the first four lines, namely:

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] –databases [OPTIONS] DB1 [DB2 DB3…]
OR     mysqldump [OPTIONS] –all-databases [OPTIONS]
For more options, use mysqldump –help


Once these had been removed the database imported just fine. Happy days!

  • Dave

    This is a test comment