mysql backup and restore

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

example:

mysqldump wordpress -u useranme -p > outputfilename.sql
Enter password:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s