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

Do you like HowtoForge? Please consider to support us by becoming a subscriber.
Submitted by falko (Contact Author) (Forums) on Mon, 2006-08-07 16:16. :: MySQL

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


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Reinier Battenberg (not registered) on Wed, 2009-01-14 09:07.

If you want to dump all databases in your server (for backup or migrating purposes) you can add the

--all-databases

option. Very useful.