MySQL Backup

Tags:

Here's a simple command line example of a backup task for MySQL.

mysqldump <DB_NAME> -v -u <MYSQL_USERID> --password=<MYSQL_PASSWORD> > sql_file_name.sql

Let's break this down.

  • <DB_NAME> - The name of the database to dump.

  • -v - This outputs some dump information. You can add more than one of these (-vvv) for a very detailed dump information.

  • -u <MYSQL_USERID> - This is the userid of the database owner in MySQL.

  • --password=<MYSQL_PASSWORD> - This is the password of the database owner in MySQL.

  • sql_file_name.sql - This is the name of the sql output file which will contain all of the dump information for the database.

If you want to dump all databases under the <MYSQL_USERID>, replace <DB_NAME> with --all-databases.

If you want to do a remote dump of a database, add -h <WEB_ADDRESS>. Example:

mysqldump -h <WEB_ADDRESS> <DB_NAME> -v -u <MYSQL_USERID> --password=<MYSQL_PASSWORD> > sql_file_name.sql

For more information using mysqldump, go to http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html