PURGE MASTER LOGS
PURGE {MASTER|BINARY} LOGS {TO 'log_filename'|BEFORE 'date'}This statement deletes the binary logs from a master server. The keywords
MASTER and BINARY are synonymous
and one is required for the statement. Log files are deleted
sequentially from the starting log file to the one named with the
TO clause, or up until (but not including) the date
named with the BEFORE clause. Here is an example of
each method:
PURGE MASTER LOGS TO 'log-bin.00110'; PURGE MASTER LOGS BEFORE '2004-11-03 07:00:00';
Before running this statement, it would be prudent to make a
backup of the logs. Then use SHOW SLAVE STATUS on each
slave to determine which logs the slaves are reading, and run
SHOW BINARY LOGS on the master server to get a list
of log files. The oldest log file in the list is the one that will be
purged. If the slaves are current, they shouldn’t be reading this log
file. If they still are, you might not want to purge it. If you find
that your log files aren’t being rotated very often, you can set the
system variable expire_logs_days to shorten the amount of time before new log files are
created and old ones archived.