清理bin-log日志(mysql-bin日志清理)

来源:互联网 发布:复杂网络基础 编辑:程序博客网 时间:2024/06/05 06:05

清理bin-log日志(mysql-bin日志清理),主从复制中的机器不要使用此方法。

1.查看档案
mysql> show binary logs;
+----------------+-----------+
| Log_name | File_size |
+----------------+-----------+
| ablelee.000001 | 150462942 |
| ablelee.000002 | 125 |
| ablelee.000003 | 106 |
+----------------+-----------+

2.删除bin-log(删除ablelee.000003之前的而没有包含ablelee.000003)
mysql> purge binary logs to 'ablelee.000003';
Query OK, 0 rows affected (0.16 sec)


3. 查询结果(现在只有一条记录了.)
mysql> show binlog events\G
*************************** 1. row ***************************
Log_name: ablelee.000003
Pos: 4
Event_type: Format_desc
Server_id: 1
End_log_pos: 106
Info: Server ver: 5.1.26-rc-log, Binlog ver: 4
1 row in set (0.01 sec)
(ablelee.000001和ablelee.000002已被删除)
mysql> show binary logs;
+----------------+-----------+
| Log_name | File_size |
+----------------+-----------+
| ablelee.000003 | 106 |
+----------------+-----------+
1 row in set (0.00 sec)

0 0