How to remove / purge MySQL binglos ?

By default, MySQL 5.x and above enables MySQL Binary Log. Keeping MySQL Binary Log will take up a lot of disk space for long run. Older MySQL Binary log can be removed in order to keep your hard disk space free.

MySQL Binary Log stores query event such as add, delete and update in a very details way.

The Binary Log is used for two main purposes:

  1. Replication between master and slave server, statement that has been made on Master server will later send it to slave server.
  2.  Recovery, certain recovery job required data stored in MySQL Binary Log.

Binlogs Location

MySQL binglogs usually stored in mysql root folder, in centos it’s usaully (/var/lib/mysql/) 

To cleanup binary logs on a slave server:

  1. Login to mysql from the command lineshell> mysql -u username -p
  2. To clean binary logs older than a specific date.mysql> PURGE BINARY LOGS BEFORE ‘2018
  3. -12-15 00:00:00′;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.