文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>MySQL log 文件清理

MySQL log 文件清理

时间:2010-11-22  来源:秩名


最近两三天发现服务器不知什么疯狂地用了几G空间,非常不解



du -s * | sort -nr | head

一步步查竟然发现时mysql log 文件占用了这几个G的空间。

[root@phpfans var]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Command
Your MySQL connection id is 29
Server version: 5.1.45-log Source dist

Type 'help;' or '\h' for help. Type '\

mysql> show binary logs;
+------------------+------------+
| Log_name | File_size |
+------------------+------------+
| mysql-bin.000001 | 19091 |
| mysql-bin.000002 | 716893 |
| mysql-bin.000003 | 263 |
| mysql-bin.000004 | 125 |
| mysql-bin.000005 | 106 |
| mysql-bin.000006 | 125 |
| mysql-bin.000007 | 125 |
| mysql-bin.000008 | 125 |
| mysql-bin.000009 | 18410 |
| mysql-bin.000010 | 716893 |
| mysql-bin.000011 | 343193 |
| mysql-bin.000012 | 125 |
| mysql-bin.000013 | 4720 |
| mysql-bin.000014 | 3457954 |
| mysql-bin.000015 | 6320 |
| mysql-bin.000016 | 771 |
| mysql-bin.000017 | 1073765162 |
| mysql-bin.000018 | 1073832354 |
| mysql-bin.000019 | 1074427810 |
| mysql-bin.000020 | 1074577144 |
| mysql-bin.000021 | 1074054970 |
| mysql-bin.000022 | 1073753406 |
| mysql-bin.000023 | 1073745728 |
| mysql-bin.000024 | 1073743401 |
| mysql-bin.000025 | 692916366 |
| mysql-bin.000026 | 685 |
+------------------+------------+
26 rows in set (0.00 sec)

可以看到从17-24这几个文件每个到达到1G左右。足足占了8G空间。非清理不可了

mysql> purge binary logs to 'mysql-bin.000025';
Query OK, 0 rows affected (11.69 sec)

删除 25 以回的log文件。

mysql> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000025 | 692916366 |
| mysql-bin.000026 | 685 |
+------------------+-----------+
2 rows in set (0.00 sec)

mysql>

执行后可以看到25以回的log文件已经被清除


 

标签分类:

相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载