mysqldump command - how to dump (backup) a MySQL database

MySQL FAQ - How do I dump a MySQL database schema?

Answer: Use the mysqldump utility.

On a dos/windows pc with no name/password protection, you can dump a database named m y_db like this:

  mysqldump my_db

Note that this gets you not only the schema, but also the current data in the table.

It is usually much more helpful to redirect this to a file:

  mysqldump my_db > my_db.sql

In a more complex example where you must know the username and password to dump the database this command will work:

mysqldump --opt --user=root --password my_db > my_db.sql

Note that mysql will prompt you for the database password.

Post new comment

The content of this field is kept private and will not be shown publicly.