這篇文章主要介紹“mysql怎么清除binlog日志”,在日常操作中,相信很多人在mysql怎么清除binlog日志問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”mysql怎么清除binlog日志”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
定期清理binlog日志可以避免磁盤滿導致數據庫異常關閉
1、按文件:刪除mysql-bin.000354之前的日志,不包含mysql-bin.000354
MYSQL>purge binary logs to 'mysql-bin.000354';
Query OK, 0 rows affected (0.16 sec)
2、按時間:刪除2011-11-10 00:00:00 之前的日志
MYSQL>purge binary logs before '2011-11-10 00:00:00';
3、按時間:請理三天之前的日志
MYSQL> purge master logs before date_sub(now(), interval 3 day);
自動清理日志 :
4、修改my.cnf文件配置bin-log過期時間
[mysqld]
expire-logs-days=7
max-binlog-size=268435456
到此,關于“mysql怎么清除binlog日志”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注創新互聯-成都網站建設公司網站,小編會繼續努力為大家帶來更多實用的文章!