一、准备
Python 2.7;
Python 3.4 or Python 3.5 or Python 3.6;
MySQL 5.5 or MySQL 5.6 or MySQL 5.7;
二、Mysql 配置
1. Mysql 开启 binlog
查看 Mysql 是否开启 binlog show variables like 'log_bin' 如果 Value 为 OFF 则为未启日志文件。
找到 my,cnf 中 [mysqld] 添加如下
[mysqld]
# binlog 配置
server-id = 1
# 目录需要有写的权限
log-bin = /var/lib/mysql-binlog/mysql-bin.log
expire-logs-days = 10
max-binlog-size = 100M
binlog-format = row
重启mysql后 show variables like 'log_bin' , Value 为 ON即可
查询binlog 变动信息 show binlog events;
Binlog要满足如下条件:
MySQL> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------