MySQL – Recovery Procedure

disaster recoveryMySQL

After the server die, I have "old" HD (it is external now) with sock file and data files in mysql directory. Where I should find information how to restore the data in fresh installed MySQL?

What will happens if I replace files and folders brutal way?

UPD:

  • Old files have a version mysql-5.1.62-osx10.6-x86_64
  • New installation have a version mysql-5.6.22-osx10.8-x86_64

Best Answer

Since MYISAM is a filebased Databasesystem that stores Tables in files, it might be possible to just copy the folder of your database into your data folder of your MySQL installation.

BUT if you are using INNODB or something else for any of your tables then it might run into problems.

Easiest way to check that would be to just set up a mysql installation on any other machine (for the sake of systemsanity you can just set up an XAMPP or LAMMP and use that for short term) and copy your files into the data folder and check if all tables you know of are there and accessible.

Once that is done you can acces that seperate system to do an export via a backup Tool of your choice (mysqldump is also possible) and then input the backup you just made into the production server.

Next step would be to set up a nice backup for your new production machine (at least once or twice a day depending on the load of data that will be put into your machine) so that dataloss is limited.

If you want to be really shure and have verry frequent backups without killing your production system you can set up a replication system where the production server works as a master and replicates all data to the slave which will be the backup server. On the slave you then do the backup in a way you are comfortable (using mysqldump or some more sophisticated tool). In case the production server crashes again, you have your backups AND the slave server that could be easily swapped and work as a fast response short term replacement.