查看MySQL是否开启binlog(进mysql操作)
show variables like 'log_bin%';
2. 查询binlog文件名
show master status;
路径一般在安装的mysql/data 下
进入 mysqlbinlog 运行文件目录 一在mysql/bin下
执行
mysqlbinlog --no-defaults ../data/mysql-bin.000012 >b.log
1、查询时间段内日志的执行内容
mysqlbinlog --start-datetime='2018-01-08 02:01:00' --stop-datetime='2018-01-08 02:30:10' -d test /var/lib/mysql/mysql-bin.000170 -v
2、查询时间段内日志中执行的删除语句
mysqlbinlog --start-datetime='2018-01-08 02:01:00' --stop-datetime='2018-01-08 02:30:10' -d test /var/lib/mysql/mysql-bin.000170 -v|grep DELETE -A 5
3、统计时间段内日志中执行的删除语句
mysqlbinlog --start-datetime='2018-01-08 02:01:00' --stop-datetime='2018-01-08 02:30:10' -d test /var/lib/mysql/mysql-bin.000170 -v|grep DELETE |wc -l