MySQL log 文件清理[网站编程]
本文“MySQL log 文件清理[网站编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
近来两三天发现服务器不知什么猖獗地用了几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文件已经被排除
以上是“MySQL log 文件清理[网站编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |