MySQL Backup/Restore database

The following command will back up your MySQL database to a file.

mysqldump --add-drop-table -u user -p database > outputfile.sql

The following will restore your database.

mysql -u root -p database < outputfile.sql

Or for a complete server back up and compression:

mysqldump -u root -p --all-databases | gzip > output.sql.gz