快速清理binlog文件

  sre

1、关闭binlog或者配置expire_logs_days,重启;
2、更改expire_logs_days,不需要重启;
> show binary logs;
> show variables like ‘%log%’;
> set global expire_logs_days = 10;
3、手动清除binlog文件,不需要重启:
> PURGE MASTER LOGS TO ‘MySQL-bin.010’; #清除MySQL-bin.010日志
> PURGE MASTER LOGS BEFORE ‘2018-01-17 00:00:00’; #清除2018-01-17 00:00:00前binlog日志
> PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 3 DAY); #清除3天前binlog日志BEFORE,变量的date自变量可以为’YYYY-MM-DD hh:mm:ss’格式。
4、重置master,删除所有binlog文件
reset master

One Reply to “快速清理binlog文件”

LEAVE A COMMENT

Captcha Code