Backing up and Dumping Mysql Databases
Last updated:dump a database into file using mysqldump
Replace <username>
, <password>
and <dbname>
with your specific values:
mysqldump -u <username> -p<password> <dbname> > /tmp/dump.sql
use a dump created by mysqldump to populate a database
The dump created in the last step is just a series of sql statements that can be used to populate a database. If the dump has been created at /tmp/dump.sql
, then we should do the following:
Log in to mysql. Replace <username>
, <password>
with your own.
mysql -u <username> -p<password>
once inside the mysql cli interface, select a database. Replace <dbname>
with your database name.
use <dbname>;
then load the dump file into this database:
source /tmp/dump.sql;