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
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
mysqldump wordpress -u useranme -p > outputfilename.sql