Backup and restore MySQL

I used backup/restore to move my databases from one server to another.

Here’s the quick notes for next time :p

Dump all the interesting databases:

# mysqldump -u root –single-transaction -p mysql > mysql.dump
# mysqldump -u root –single-transaction -p wordpress > wordpress.dump
# mysqldump -u root –single-transaction -p zarafa > zarafa.dump

Restore the databases from an already existing database, empty or not:

# mysql -u root -p mysql < mysql.dump # mysql -u root -p wordpress < wordpress.dump # mysql -u root -p zarafa < zarafa.dump

Finally, check the status of the databases and repair if needed:

# mysqlcheck -u root -p -c -A
(...)
wp.wp_blc_links
warning  : 1 client is using or hasn't closed the table properly
status   : OK
(...)
# mysqlcheck -u root -p -r wp wp_blc_links
# mysqlcheck -u root -p -r wp wp_options wp_postmeta wp_posts wp_term_relation
Enter password:
wp.wp_options                                      OK
wp.wp_postmeta                                     OK
wp.wp_posts                                        OK
wp.wp_term_relationships                           OK

That’s all folks!

Source: Backup and Restore MySQL Databases

No Comments

Leave a Reply

%d bloggers like this: