8 Ocak 2012 Pazar

Mysql Backup and Restore

Backup

You can use mysqldump to create a simple backup of your database using the following syntax.

mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]


Following is an example of a database backup command:

mysqldump -u mysql_user -p mysql_pass clipbucket > clipbucket.sql


Restore 

The dump file retrieved from from mysqldump command can be restored using mysql command. Following is the general format of restore command: 

mysql -u [username] -p [password] [database_to_restore] < [backupfile] 


Following is an example of a database restore command:

mysql -u mysql_user -p mysql_pass clipbucket_2 < clipbucket.sql