问题
when I run below statement, mysql is complaining having error.
mysqldump --triggers --routines -u root -p mydb > mydb_20120924.dmp;
mysql version: 5.1.34
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 'mysqldump --triggers --routines -u root -p mydb > mydb_20120924.dmp' at line 1
回答1:
It looks like you are trying to run the mysqldump command from inside the mysql command line interpreter.
Does the prompt for the mysqldump command say 'mysql> '? Then you are running the mysql command line interpreter. It should be used - indeed, it can only be used - for running mysql commands.
mysqldump is a separate command and must be run from the shell.
Quit mysql by typing "exit" - you will see a shell prompt. Then the mysqldump command will work.
回答2:
If you have a database called "mydb" this should work. You could try using --database specifically:
mysqldump --triggers --routines -u root -p --database mydb > mydb_20120924.dmp;
来源:https://stackoverflow.com/questions/12560362/dumping-db-in-mysql