Backup a MySQL database

I’ll just quickly cover some options here to backup a MySQL database.

The first will output all the data and all the databases along with the schema:

mysqldump -u <user> -p -h <hostname> --all-databases > all_databases.sql

The next option will output just the schema for all of the databases:

mysqldump -d -u <user> -p -h <hostname> --all-databases > all_databases.sql

Now we can use the same two methods above but replace –all-databases with the name of a database to output just one.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">