Automatic cleanup Dynamic settings
Executes the query in the terminal to check the current binary log timeout.
The default is 0, which means never time out
mysql> show variables like
‘%expire_logs_days%‘
;
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days |
0
|
+------------------+-------+
1
row in set (
0.00
sec)
Set retention for 14 days with the following command
set
global
expire_logs_days = 14;
triggered automatically when MySQL switches logs.
can be flush logs by command; Trigger manually. (manual triggering is not recommended)
Configuration file
The run-time settings are not valid after a restart, and the configuration file needs to be set to ensure that the restart is valid.
/etc/my.cnf
[Mysqld]
expire_logs_days=
14
can be manually cleaned by the following command, due date or file name.
-- 截止到 2016-07-01 00:00:00
PURGE MASTER LOGS BEFORE
‘2016-07-01 00:00:00‘
;
-- 截止到文件 mysql-bin.001000
PURGE MASTER LOGS
TO
‘mysql-bin.001000‘
;
This article is from the "Intelligent Future _XFICC" blog, please be sure to keep this source http://xficc.blog.51cto.com/1189288/1833337
MySQL cleanup binary log (XF version)