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

Want to support HowtoForge? Become 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 Anonymous (not registered) on Thu, 2010-09-02 20:19.
Yes, it works. Thanks
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.