mysql> show master status;
+---------------+-----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+-----------+--------------+------------------+-------------------+
| binlog.000041 | 744511437 | | | |
+---------------+-----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> show variables like "expire_logs_days";
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 0 |
+------------------+-------+
1 row in set (0.04 sec)
在mysql的配置文件/etc/my.cnf
添加内容
expire_logs_days = 7
重启mysql服务
# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
重新进入数据库
show variables like "expire_logs_days";
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| expire_logs_days | 7 |
+------------------+-------+
1 row in set (0.05 sec)
mysql>