How to backup mysql database (command line)

To backup:

mysqldump -u username -p database_to_backup > backup_name.sql

To restore:

mysql -u username -p
CREATE DATABASE database_name;
exit

mysql -u username -p database_name < backup_name.sql

Leave a Reply