Backup & Restore mySQL database | quick guide

Create a backup:

mysqldump -u username -p password --databases database1 database2 db_name3 > multi_db_names.sql
mysqldump --all-databases > alldatabases.sql
mysqldump --all-databases | bzip2 -c > databasebackup.sql.bz2
mysqldump --all-databases | gzip > databasebackup.sql.gz

Restore from a backup:

mysql -u [username] -p [password] [database_to_restore] < [backupfile] gunzip < backup_name.sql.gz | mysql -u username -p password db_name

If you have to put username & password in full:

mysql --user=root --password=mysecretpassword virtualad_db < virtualad_db2010-06-28.sql

And my working sample:
mysql -u root -p -h keywords < keywords_dump_db.sql

Posted on June 28, 2010 at 12:55 by admin · Permalink
In: mySQL

Leave a Reply