mysql 日志文件mysql-bin文件清除方法,和mysql-bin相关文件的配置
默認(rèn)情況下mysql會(huì)一直保留mysql-bin文件,這樣到一定時(shí)候,磁盤可能會(huì)被撐滿,這時(shí)候是否可以刪除這些文件呢,是否可以安全刪除,是個(gè)問(wèn)題。
首先要說(shuō)明一下,這些文件都是mysql的日志文件,如果不做主從復(fù)制的話,基本上是沒(méi)用的,雖然沒(méi)用,但是不建議使用rm命令刪除,這樣有可能會(huì)不安全,正確的方法是通過(guò)mysql的命令去刪除。
mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2819416 Server version: 5.5.24-0ubuntu0.12.04.1-log (Ubuntu) Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> reset master; Query OK, 0 rows affected (3 min 37.65 sec)其實(shí)關(guān)鍵的命令就是reset master;這個(gè)命令會(huì)清空mysql-bin文件。
另外如果你的mysql服務(wù)器不需要做主從復(fù)制的話,建議通過(guò)修改my.cnf文件,來(lái)設(shè)置不生成這些文件,只要?jiǎng)h除my.cnf中的下面一行就可以了。
log-bin=mysql-bin如果你需要復(fù)制,最好控制一下這些日志文件保留的天數(shù),可以通過(guò)下面的配置設(shè)定日志文件保留的天數(shù):
expire_logs_days = 7表示保留7天的日志,這樣老日志會(huì)自動(dòng)被清理掉。
轉(zhuǎn)載于:https://www.cnblogs.com/wangluochong/p/5484989.html
總結(jié)
以上是生活随笔為你收集整理的mysql 日志文件mysql-bin文件清除方法,和mysql-bin相关文件的配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: LAMP自动化部署
- 下一篇: 【 转 】Keepalived工作原理