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

Do you like HowtoForge? Please consider supporting 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.

Sponsored Links: Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com

One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com

One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com

One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com

AT&T Synaptic Compute as a Service. Boost your power on demand.

Trial: IBM Cognos Express Reporting, Analysis & Planning