We’ve already shown you how to create a backup of your MySQL server from the command line, but it’s very important to know how to restore that data just in case you should need to recover from a failure. You should also make a point of testing out your recovery process on another box, just to make sure it’s working properly.
The syntax to restore your database from the command line:
mysql -h hostname -u username -pthepassword databasename < dumpfile.sql
Here’s an example:
mysql -h localhost -u root -p72aDufi8 db01 < thedumpfile.sql
Keep in mind that this will pretty much wipe your current database, so proceed with caution.
Programmer by day, geek by night, The Geek, also known as Lowell Heddings, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on Google+ if you'd like.
- Published 12/18/09