Today MySQL server disk space exhaustion, after the discovery of MySQL directory generated a large number of binary log files, occupy dozens of g of disk space, almost 3,000 files, such as
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/44/wKioL1V39EagUaejABAKFWxMw_M384.jpg "title=" MySQL binary file. png "alt=" wkiol1v39eaguaejabakfwxmw_m384.jpg "/>
Enter MySQL to view the relevant log settings
mysql> show variables like '%log% '; +-----------------------------------------+--------- ------------------------------------+| variable_name | Value |+-----------------------------------------+------------------------------ ---------------+| back_log | 50 | | binlog_cache_size | 32768 | | binlog_direct_non_transactional_updates | OFF | | binlog_format | mixed | | expire_logs_days | 0 #这个默认是0, i.e. logs
This is done by manually deleting these log files and then setting the value of Expire_logs_days, which is automatically deleted for more than 7 days.
Mysql> purge master logs to ' mysql-bin.002970 '; #表示将主库的日志记录清除到以 ' mysql-bin.002970 ' for the beginning of the log. Query OK, 0 rows affected (1 min 30.29 sec) mysql> set global expire_logs_days=7; #这个是全局变量, restarting MySQL will not take effect. Query OK, 0 rows Affected (0.00 sec)
Another way is to modify the/ETC/MY.CNF, add a line below the mysqld. Restart MySQL for permanent entry, only 7 days of binary logs are reserved.
Expire_logs_days = 7
This article is from the "operations, hello" blog, please be sure to keep this source http://denghaibin.blog.51cto.com/4128215/1660494
MySQL Large batch delete log