Backing up a MySQL Database

// March 24th, 2009 // Database, MySQL

Using cmd prompt in Windows, navigate to the bin directory where MySQL has been installed. There will be a file called “mysqldump.exe” in that directory. Enter the following command:

mysqldump -u root -ppass --databases your_db > backup.sql

Notice that there is no space between the -p and the password, this is a bug in MySQL.

The backup.sql file will be created in the directory that you are in. You can specify C:\your_db.sql if you want the file to be backed up on the C:\ drive.

If you want to backup the structure only, use -d for the “–no-data-option”. For example:

mysqldump -u root -ppass -d --databases your_db > backup.sql

Leave a Reply