天天看點

如何删除mysql-bin.0000X 日志檔案

一、資料庫版本

Server version: 5.1.40

二、進入資料庫

[[email protected] ~]# mysql -uroot  -p

Enter password:  輸入密碼

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 31114

Server version: 5.1.40-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 

    2、檢視日志檔案 

 mysql> show master logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000063 |  12572632 |

| mysql-bin.000064 |    116575 |

| mysql-bin.000065 |  11140064 |

| mysql-bin.000066 |   7754187 |

| mysql-bin.000067 |     31984 |

| mysql-bin.000068 |   1019530 |

| mysql-bin.000069 |   2732931 |

| mysql-bin.000070 |    308131 |

| mysql-bin.000071 |  12101585 |

| mysql-bin.000072 |      1655 |

| mysql-bin.000073 |  26374833 |

| mysql-bin.000074 |  17866915 |

| mysql-bin.000075 |       125 |

| mysql-bin.000076 |     77987 |

| mysql-bin.000077 |     71104 |

| mysql-bin.000078 |       125 |

| mysql-bin.000079 |       125 |

| mysql-bin.000080 |       125 |

| mysql-bin.000081 |     62067 |

| mysql-bin.000082 |       106 |

| mysql-bin.000083 |       106 |

| mysql-bin.000084 |       106 |

| mysql-bin.000085 |    214510 |

| mysql-bin.000086 |      2188 |

| mysql-bin.000087 |       125 |

| mysql-bin.000088 |   8736376 |

| mysql-bin.000089 |       149 |

| mysql-bin.000090 |     15818 |

+------------------+-----------+

28 rows in set (0.00 sec)

    3、清除日志檔案

mysql> reset master;

Query OK, 0 rows affected (0.51 sec)

三、修改my.cnf配置檔案

既然mysql-bin.0000X日志檔案占用這麼大空間,存在的意義又不是特别大,那麼我們就不讓它生成吧.

[[email protected] ~]# vim /etc/my.cnf

我們将log-bin=mysql-bin 這條注釋掉即可.

重新開機下mysql吧.

OK,至此,操作完成. 以後再不會因為就幾十M的資料庫大小生成N個G的日志檔案啦.

本文轉自 kuangling 51CTO部落格,原文連結:http://blog.51cto.com/kling/1152334