Name

PURGE MASTER LOGS

Synopsis

PURGE {MASTER|BINARY} LOGS {TO 'filename'|BEFORE 'date'}

Use this statement to delete 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 logfile 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';

Use the SHOW MASTER LOGS statement to obtain a list of logfiles before purging. When using slave servers, run the SHOW SLAVE LOGS statement on each slave to determine the oldest log that is still in use before deciding which logfiles to delete. It would also be prudent to make a backup of the logs before running this statement.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.