This MySQL statement deletes the binary logs from a master server.
hits past month: 6 ; last updated: may 4, 2009 - 2:34am ; parent: MySQL ReplicationPURGE {MASTER|BINARY} LOGS {TO 'log_filename'|BEFORE 'date'}
This MySQL statement deletes the binary logs from a master server running replication. 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 using this MySQL statement:
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 the MySQL statement, SHOW SLAVE STATUS on each replication 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 them. 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.