Monday, February 15, 2016

Purge MySQL binary logs

6:34 AM Posted by Dilli Raj Maharjan No comments
The binary log is a set of files that contain information about data modifications made by the MySQL server. These files are generated on master server while bin log is enabled. Over the time the number of those bin log files grows and need to clean on regular basic. Purge binary log will delete binary logs on basic of the give values so It is recommended to backup those binary log files into tape or external drives for future.


We can purge binary on basic of log_name or date before expression.

PURGE BINARY LOGS
    { TO 'log_name' | BEFORE datetime_expr };

PURGE BINARY LOGS TO 'master-bin.010';

Deletes all binary log that are created before master-bin.010.


PURGE BINARY LOGS BEFORE '2016-01-01 00:00:00';
Deletes all binary log that are created before January 1st 2016.

As shown on figure below I have around 10% space free.



More than 52 binary log files are created. I need to purge them.










Execute purge command so that it will be deleted from OS and from MySQL metadata.

Purge binary log to 'master-bin.000400';



Verify the files are deleted from OS side.












0 comments:

Post a Comment