Binlog2sql can reverse parse the Binlog, generate the corresponding recovery statement, and then execute it manually to the database, which is not valid for operations such as Drop,truncate.
1、安装
A. Need to install Python and pip
b, after the decompression binlog2sql
CD to Directory
Execute PIP install-r requirements.txt
You can do it.
2、用户需要的权限
Select, replication slave, replication Client on .
3、binlog格式
Binlog_format must be row
4、确定pos号
Fast positioning to avoid large amounts of unnecessary information
Show Binlog events in ' mysql-bin.000039 ';
or Mysqlbinlog--base64-output
5、解析指定binlog中执行过的sql
Note that--start-file directly fill in the Binlog name, do not add the path
The command is as follows:
Python binlog2sql.py-h192.168.1.165-p3306-uflashuser-p111111-dtest-t tbl--start-file= ' mysql-bin.000039 '-- start-position=133130--stop-position=1683306
6、反转sql语句
The command is as follows:
Python binlog2sql.py--flashback-h192.168.1.165-p3306-uflashuser-p111111-dtest-t tbl--start-file= ' mysql-bin.000039 '--start-position=133130--stop-position=1683306
And put these statements back to MySQL for execution.
Binlog2sql Tools easy to use instructions