mysql日志清理

mysql>SHOW MASTER LOGS;
此命令显示目前二进制日志的数目。
然后
mysql> PURGE MASTER LOGS TO ‘binary-log.xxx’;

 mysql > flush logs;

 mysql > reset master;


除了命令中给出的日志之后的外,其他的二进制日志全部删除。

具体如下:
PURGE MASTER LOGS

PURGE { MASTER|BINARY } LOGS TO ‘log_name’
PURGE { MASTER|BINARY } LOGS BEFORE ‘date’

Deletes all the binary logs listed in the log index that are strictly prior to the specified log or date. The logs also are removed from this list recorded in the log index file, so that the given log now becomes the first.

Example:

PURGE MASTER LOGS TO ‘mysql-bin.010′;
PURGE MASTER LOGS BEFORE ’2003-04-02 22:46:26′;

The BEFORE variant is available in MySQL 4.1; its date argument can be in ‘YYYY-MM-DD hh:mm:ss’ format. MASTER and BINARY are synonyms, though BINARY can be used only as of MySQL 4.1.1.

If you have an active slave that is currently reading one of the logs you are trying to delete, this command does nothing and fails with an error. However, if you have a dormant slave, and happen to purge one of the logs it wants to read, the slave will be unable to replicate once it comes up. The command is safe to run while slaves are replicating. You do not need to stop them.

You must first check all the slaves with SHOW SLAVE STATUS to see which log they are reading, then do a listing of the logs on the master with SHOW MASTER LOGS, find the earliest log among all the slaves (if all the slaves are up to date, this will be the last log on the list), backup all the logs you are about to delete (optional) and purge up to the target log.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值