指定过期天数(expire_logs_days) ---适用于单机版mysql!
该参数为全局可动态调整参数,默认值为0,即关闭,取值范围0-99。
1.3.1 参数的查看:
mysql> show variables like 'expire_logs_days';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 0 |
+------------------+-------+
1.3.2 参数调整:
例如我们设置过期为60天
设置完后红色标注的3个binlog日志将会被删除。
设置参数:
mysql> set global expire_logs_days = 60;
Query OK, 0 rows affected (0.05 sec)
mysql> show variables like 'expire_logs_days';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 60 |
+------------------+-------+
刷新日志查看,上述三个日志被清除掉了。
mysql> flush logs;
Query OK, 0 rows affected (0.07 sec)
mysql> show master logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000013 | 4097 |
| mysql-bin.000014 | 54431 |
| mysql-bin.000015 | 729 |
| mysql-bin.000016 | 107 |
————————————————