Home  >  Article  >  Database  >  清除并禁用MySQL的Binary logs_MySQL

清除并禁用MySQL的Binary logs_MySQL

WBOY
WBOYOriginal
2016-06-01 13:32:09915browse

bitsCN.com

清除并禁用MySQL的Binary logs

 

最近 MySQL 一下子飞黄腾达了,Binary Log 吃掉 800 MiB 多的硬盘空间,干扰了系统的正常运行。解决的方法有很多,包括直接删除文件,逐个使用 SQL 语句清除日志等。但我还是倾向于使用标准的操作方法。

 

关掉它

 

编辑 /etc/mysql/my.cnf,找到 log-bin 选项,注释掉;如果有 expire_logs_days,同样注释掉。

 

...# log-bin# expire_logs_days = 10...

 

 

清除已有日志

 

首先使用 mysql -u root -p 登录服务器。

 

SHOW BINARY LOGS;

 

 

首先看看我们有多少日志,占用了多少空间。真是不少啊。

 

+-------------------+-----------+| Log_name          | File_size |+-------------------+-----------+| mysqld-bin.000001 |       264 || mysqld-bin.000002 |      1546 || mysqld-bin.000003 |     11728 || mysqld-bin.000004 | 122291346 || mysqld-bin.000005 |       264 || mysqld-bin.000006 |       958 || mysqld-bin.000007 |     85263 || mysqld-bin.000008 |    467392 || mysqld-bin.000009 |    271736 || mysqld-bin.000010 |       264 || mysqld-bin.000011 |      2670 || mysqld-bin.000012 |   5258576 || mysqld-bin.000013 |     25406 || mysqld-bin.000014 |    430000 || mysqld-bin.000015 |    560172 || mysqld-bin.000016 |  45971600 || mysqld-bin.000017 |  62227475 || mysqld-bin.000018 | 223992121 || mysqld-bin.000019 |  91294894 || mysqld-bin.000020 |   4796916 |+-------------------+-----------+FLUSH LOGS;RESET MASTER;

 

至此,Binary Logs 被彻底禁用。

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn