mysqlbinlog command

The “mysqlbinlog” command reads the binary logs and outputs them in SQL format. As a result, you can use it to create a database dump and then modify that file by hand. For example, let’s say that everything since April 10th, 10AM server time needs to be restored (leaving out one statement). We would first use this command:

mysqlbinlog –start-datetime=”2013-04-10 10:0:00″ /var/log/mysql/bin.123456 > output.sql

to create the database dump. After this file is created, we can delete the offending statement that we would not want re-run. Alternately, if you know the specific binary log position, you can use the –start-position flag. Here are some articles on this process:

http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html
http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery-times.html
http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery-positions.html

About vicki

Welcome to the Sovereign Republic of Vickistan. I am the President here. Lucky me! No taxes or laws yet. Lucky you!
This entry was posted in Linux. Bookmark the permalink.