MySQL - Dump and Reload

mysql

mysqldump --password --user=root world > world.sql
create database world;
mysql -u root -p world < world.sql
mysqldump -h myhost -u root -pmypass dbname > dbname_backup.sql

To restore:

mysqladmin -h myhost -u root -pmypass create dbname;
mysql -h myhost -u root -pmypass dbname < dbname.sql

To dump schema only:

mysqldump -u someuser -p -d --routines mydatabase > mydatabase.sql
mysqldump -u someuser -p --no-data --routines mydatabase > mydatabase.sql
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License