Main Content

mysqldump and mysqlrestore

Archive - Originally posted on "The Horse's Mouth" - 2007-03-30 14:55:56 - Graham Ellis

It is vital that you back up your data ... and if you hold your data in a MySQL database, then the mysqldump utility will do the job admirably for you.

It is equally vital that you can restore the data from backup if (heaven forbid) you need to do so ... and yet there is not a mysqlrestore utility.

Why so? How do I restore dumped data?

Mysqldump saves data in the form of SQL commands which can be typed in to the mysqlclient program .... and tha program supports a source command which allows the user to bring in the data from a named file.

Want to see an example? Let's use MySQLDump and MySQL to dump a database (called imageapp) from one server (called liveserver) and restore it, inder a new name (imgappcopy), on another server (devserver):
mysqldump -hliveserver -uroot -p imageapp > images.sql
mysql -hdevserver -uroot -p
create database imgappcopy;
use imgappcopy;
source images.sql