Backup:

mysqldump --add-drop-table -h localhost -u root -p database_name > backup_filename.bak.sql

To restore, first create database database_name in MySQL, then

mysql -h localhost -u root -p database_name < backup_filename.bak.sql