Tuesday, October 14, 2008

How to Back Up and Restore a MySQL Database

Backup:
[/bin/nice -n 19] mysqldump -u [uname] -p [dbname] -c | [/bin/nice -n 19] | gzip -9 > [backupfile.sql.gz]

Note: You can use $(date '+%Y.%m.%d').sql.gz like I do for the name.


Restore:
gunzip [backupfile.sql.gz]
mysql -u [uname] -p [db_to_restore] < [backupfile.sql]


How to Back Up and Restore a MySQL Database

No comments: