How do I make an sql dump of a MySQL database on the command line?

If your MySQL user has a password:

mysqldump -h localhost -u [MySQL user, e.g. root] -p[database password] -c --add-drop-table --add-locks --all --quick --lock-tables [name of the database] > sqldump.sql

Please note:  there's no space between -p and the password!

If there's no password:

mysqldump -h localhost -u [MySQL user, e.g. root] -c --add-drop-table --add-locks --all --quick --lock-tables [name of the database] > sqldump.sql
Share this page:

2 Comment(s)