[mysqld]
server_id = 1
log_bin = /var/log/mysql/mysql-bin.log
max_binlog_size = 1G
binlog_format = row
binlog_row_image = full
Python 2.7, 3.4+
MySQL 5.6, 5.7
yum -y install epel-release
yum -y install git python-pip
git clone https://github.com/danfengcao/binlog2sql.git && cd binlog2sql
pip install -r requirements.txt
- 处在binlog2sql目录下,解析出基本SQL:
shell> python ./binlog2sql.py -h127.0.0.1 -P3306 -uroot -p'admin' -dnpl_system -ttest --start-file='mysql-bin.000008'
- 解析出回滚SQL,注意“--flashback”:
shell> python ./binlog2sql.py --flashback -h127.0.0.1 -P3306 -uroot -p'admin' -dnpl_system -ttest --start-file='mysql-bin.000008'
shell> python ./binlog2sql.py --flashback -h127.0.0.1 -P3306 -uroot -p'admin' -dnpl_system -ttest --start-file='mysql-bin.000008' -B > rollback55.sql | cat