MySQL – How to Recover a Broken or Damaged Database from Transaction File

MySQLrecoveryrestore

A greeting fellow, I would like to know if in MySQL (I understand that all engines must have), you can recover from damage to the database using some kind of file "journal" transactions, if so, what is that file? What is the correct procedure to recover it ?. I know that I can recover it from the * .frm files present in /var/lib/mysql, but I would also like to know this other option. And if someone dominates the subject, I will appreciate your comments.

Best Answer

The MySQL binary log is what you are looking for. Aside from being used for replication, because it stores a range of writes executed on the server, it can be used for point in time recovery.

You will need some kind of regular starting point in case of recovery (such as a full backup), and then you can use the binary logs and mysqlbinlog to roll forward to an arbitrary point in time (e.g. just before an accidental table drop). So they won't substitute backups but can complement them nicely.

Some people was able even to use them to roll back actions under specific circumstances and configuration.