How to Backup and Restore a MySQL Database
To make a database backup using the MySQL command-line utilities, execute the following command:
$ mysqldump -u username -p –opt dbname > dump.sql
It will ask you for password because we used -p paramater over there. If the MySQL programs are not in your path, you will need to manually specify the location of the mysqldump program:
$ /path-to-your-mysql-bin/mysqldump -u username -p –opt dbname > dump.sql
Download the dump.sql and keep it in a safe place (CDR, Zip disk, etc).
If you need to restore your database, you can do so like this:
$ mysql -u username -p dbname < dump.sql
This is the simples way to restore and backup your database.