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.
0 Comments
Please log in to leave a comment.