Mysql – Can you restore purged MySQL binary logs

backupbinlogMySQLmysqlbinlogrestore

I have two situations I need some clarification.

1) Let's say I made a backup of all the MySQL binary logs before I purged a single binary log file (the oldest one, possibly the very first one).

mysql-bin.000001

Can I restore this single binary log from the backup I made? Just copy and paste it from my backup to the MySQL data directory and I can use it again as if it was never deleted in the first place?


2) Another situation, let's say I purged every bin log except the current one but after a month or two I needed to restore something from the middle of the purged bin logs like:

mysql-bin.000099

Can I just restore this single file from backup and do whatever it is I need to get back from this bin single bin log file? Or I would need to restore everything before I could use that file?

Best Answer

The binlogs contain a chronological list of the changes made to all the tables. There is no "snapshot" in them, only insert, deleted, etc statements.

You can look at any one of the files with the mysqlbinlog program.

"get back from this bin single bin log file" -- What do you imagine you might want to get?