MySQL - backup or restore a database

  • Backup
mysqldump -u username -p database_to_backup > backup_name.sql
  • Restore
mysql -u username -p

CREATE DATABASE database_name;
exit
mysql -u username -p database_name < backup_name.sql