立即学习:https://edu.csdn.net/course/play/10084/221709?utm_source=blogtoedu
2、开启binlog
#vim /etc/my.cnf
[mysqld]
log_bin=/var/lib/mysql/mysqlbin
server_id=1
#systemctl restart mysqld
--查看binlog日志文件
show master status;
3、日志切换
flush binary logs;
5、二进制日志查看
show binary logs;
show binlog events;
show binlog events in 'mysqlbin.000002';
show binlog events in 'mysqlbin.000002' from 572;
6、基于mysqlbinlog方式查看二进制日志包含的内容
system mysqlbinlog /var/log/mysql/mysqlbin.000002
7、删除历史日志
purge binary log to 'mysqlbin.000002' 删除000002之前的binlog
reset master;
清除之后,日志又从000001开始。
8、日志有效期
show variables like 'expire_log%'
set global expire_logs_days=7;
vim /etc/my.cnf
expire_logs_days=7
9、二进制日志暂停(session级别)
reset master;
set sql_log_bin=0;
insert into tb1 values(2,'john');