Thursday, June 07, 2007

mysql backup and restore

I recently had to make a backup of a db I use internally and migrate it to a different server. Luckily, Mysql has built in tools to help you out.

This is a very simple way to do it. The man pages will have more information on advanced usage.

To backup the database:

- mysqldump dbname -u username -p > outputfilename.sql

I then scp'ed the dump over to my new machine, and then restored it with:

- mysql dbname -u username -p < outputfilename.sql

No comments: