MySQLのログファイルをクリーンアップ

1.du -s * | sort -nr | head

2.[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)

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

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

MySQL

Posted by arkgame