To use mysql to take a dump of a database as a backup or to migrate the database to another server use the following comand:
mysqldump -u [USERNAME] -p[PASSWORD] [DATABASE-NAME] > dumpfilename.sql
To restore the dump use the following comand:
mysql -u username -p database_name < file.sql