清理无用的mysql-bin文件

最近硬盘用的特别快,发现是mysql-bin的占用多引起的。

mysql-bin-1.png

1、 reset master;这个命令会清空mysql-bin文件。

[root@zabbix mysqldata]# mysql  -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 289502
Server version: 5.7.10-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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 (2.76 sec)

mysql> 

  • 另外如果你的mysql服务器不需要做主从复制的话,建议通过修改my.cnf文件,来设置不生成这些文件,只要删除my.cnf中的下面一行就可以了。

    log-bin=mysql-bin

  • 如果你需要复制,最好控制一下这些日志文件保留的天数,可以通过下面的配置设定日志文件保留的天数:

    expire_logs_days = 7

    表示保留7天的日志,这样老日志会自动被清理掉。


配置文件修改后 要重启mysql服务才能生效!!!


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。

文章标题:清理无用的mysql-bin文件

本文作者:wangzhirui

发布时间:2019-09-10, 11:08:03

最后更新:2025-02-27, 02:04:03

原始链接:https://wangzhirui.com/2019/09/10/清理无用的mysql-bin文件/

转载请保留原文链接及作者。

目录