Using mysqldump, you can backup a local database and restore it on a remote database at the same time, using a single command.

Here is the quick snippet of how backup and restore MySQL database using mysqldump:

backup:

mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:

mysql -u root -p[root_password] [database_name] < dumpfilename.sql

For zipped export:

mysqldump -u [user] -p [db_name] | gzip > [filename_to_compress.sql.gz]

For zipped import:

gunzip < [compressed_filename.sql.gz]  | mysql -u [user] -p[password] [databasename]

Note: There is no space between the keyword '-p' and your password.


This article was last modified: June 3, 2016, 7:49 a.m.

0 Comments

Please log in to leave a comment.

Add or change tags.

A comma-separated list of tags.

Share

Hacker News

Top