mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.22 | +-----------+ 1 row in set (0.01 sec) mysql> show variables like '%expire%'; +--------------------------------+---------+ | Variable_name | Value | +--------------------------------+---------+ | binlog_expire_logs_seconds | 2592000 | | disconnect_on_expired_password | ON | | expire_logs_days | 0 | +--------------------------------+---------+ 默认情况下binglog的失效日期为30天,设置为0则表示永不失效。 以前的参数expire_logs_days废弃不用了。 mysql> set global expire_logs_days=7; ERROR 3683 (HY000): The option expire_logs_days and binlog_expire_logs_seconds cannot be used together. Please use binlog_expire_logs_seconds to set the expire time (expire_logs_days is deprecated) mysql> set global binlog_expire_logs_seconds=4*24*60*60; Query OK, 0 rows affected (0.00 sec) mysql> flush logs; Query OK, 0 rows affected (0.06 sec) mysql> show binary logs; 说明: 在MySQL 8.0之前 使用的参数expire_logs_days 只能设置到天,在新版本可以精确到秒 。 清理日期之前的binlog日志 mysql> purge binary logs before '2021-22-20 22:00:00'; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> show binary logs;
标签:binlog,set,logs,过期,days,expire,mysql From: https://www.cnblogs.com/rtnb/p/16729798.html