Simple MySQL Backup and Restore

 

Simple mysql backups and restores

Backup (add the drop table cmd to facilitate restores without having to drop db and recreate db):
mysqldump --add-drop-table -u dbuser -p dbpass dbname > dbname.sql


Restore:
mysql -u dbuser -p dbpass dbname < dbname.sql

 

Note: the add-drop-table isn't usually necessary since the default is to add drop table to a mysqldump, but it doesn't hurt to make sure since some installs may not add this by default.