22
Oct

Backup and Restore MySQL Database

Here is an example of how to backup a MySQL database to a dump:

mysqldump -u username -h hostname -p password db_name > dump.sql

Here is an example of how to restore a MySQL database from a dump:

mysql -u username -h hostname -p password db_name < dump.sql

You can also pass in a blank value for the password option and it will prompt you for it when you run the command rather than typing it out in plain text for all to see. Food for thought.

As always, be sure to check out the man pages for mysql and mysqldump.

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 0 Comment So Far

Share your thoughts, leave a comment!