Monday, March 10, 2008

MySQL Database backups

I have had to work with MySQL a lot lately and I have learned to love it. I had been a DB2 guy for years - but I have converted. Anyway, I wanted a simple way to move my data between physical and virtual machines.

This process is so simple, the Big 3 need to sit up and take a lesson. This works in versions 4 and higher.

To backup and entire database:

mysqldump -uUSERNAME -pPASSWORD database_name > backup.sql

Simple? I think so...

To rebuild on another system, I simply create an empty database and do the following:

cat backup.sql | mysql -uUSERNAME -pPASSWORD database_name

Incredibly simple - very powerful.

No comments: