日期:2014-05-16 浏览次数:20724 次
?
?
mysql> help purge
Name: 'PURGE BINARY LOGS'
Description:
Syntax:
PURGE { BINARY | MASTER } LOGS
??? { TO 'log_name' | BEFORE datetime_expr }
The binary log is a set of files that contain information about data
modifications made by the MySQL server. The log consists of a set of
binary log files, plus an index file (see
http://dev.mysql.com/doc/refman/5.1/en/binary-log.html).
The PURGE BINARY LOGS statement deletes all the binary log files listed
in the log index file prior to the specified log file name or date.
BINARY and MASTER are synonyms. Deleted log files also are removed from
the list recorded in the index file, so that the given log file becomes
the first in the list.
This statement has no effect if the server was not started with the
--log-bin option to enable binary logging.
URL: http://dev.mysql.com/doc/refman/5.1/en/purge-binary-logs.html
Examples:
PURGE BINARY LOGS TO 'mysql-bin.010';
PURGE BINARY LOGS BEFORE '2008-04-02 22:46:26';
?
1. 查找binlog
mysql> show binary logs;
+---------------+------------+
| Log_name????? | File_size? |
+---------------+------------+
| binlog.000031 | 1078645043 |
| binlog.000032 | 1076374846 |
| binlog.000033 | 1079182704 |
| binlog.000034 |? 511795531 |
| binlog.000035 |??????? 125 |
| binlog.000036 |?? 11942121 |
| binlog.000037 |??????? 125 |
| binlog.000038 |??????? 146 |
| binlog.000039 |??????? 106 |
| binlog.000040 |????? 64616 |
| binlog.000041 |??????? 125 |
| binlog.000042 |??????? 125 |
| binlog.000043 |?????? 3875 |
| binlog.000044 |??????? 386 |
| binlog.000045 |??????? 125 |
| binlog.000046 |??????? 125 |
| binlog.000047 |??????? 125 |
| binlog.000048 |?????? 2875 |
| binlog.000049 |?????? 2081 |
| binlog.000050 |??????? 125 |
| binlog.000051 |??????? 125 |
| binlog.000052 |??????? 125 |
| binlog.000053 |????? 62110 |
| binlog.000054 |? 788661684 |
| binlog.000055 |??????? 146 |
| binlog.000056 |??????? 106 |
+---------------+------------+
?
2. 删除 bin-log
mysql> purge binary logs to 'binlog.000033';
Query OK, 0 rows affected (3.54 sec)
3.? 查询结果
mysql> show binlog events\G
?
mysql> show binary logs;
?
1 row in set (0.00 sec)
?
?
PURGE {MASTER | BINARY} LOGS TO
'log_name'