1、查询bilog是否开启
show variables like 'log_bin';
2、查询bilog过期时间
show variables like '%logs_days%'; 默认为0(为永不过期)
3、设置临时过期时间
set global binlog_expire_logs_seconds=60*60*24*2;
flush logs;(刷新方可生效)
4、手动删除bilog
1)、按日期手动删除: purge binary logs before '2020-04-22 14:00:00';
2)、按文件名删除,删除指定文件名之前的日志:purge binary logs to 'bin.000005';
5、查看binlog
/mysql/app/mariadb/bin/mysqlbinlog --no-defaults --database=db --base64-output=decode-rows -v --start-datetime='2019-04-11 00:00:00' --stop-datetime='2019-04-11 15:00:00' mysql-bin.000007 | more
6、将binlog解析并存到文件中
/mysql/app/mariadb/bin/mysqlbinlog --no-defaults --database=db --base64-output=decode-rows -v --start-datetime='2019-04-11 00:00:00' --stop-datetime='2019-04-11 15:00:00' mysql-bin.000007 >/tmp/binlog007.sql