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:
- Replication between master and slave server, statement that has been made on Master server will later send it to slave server.
- Recovery, certain recovery job required data stored in MySQL Binary Log.
MySQL binglogs usually stored in mysql root folder, in centos it’s usaully (/var/lib/mysql/)
To cleanup binary logs on a slave server:
- Login to
mysqlfrom the command lineshell> mysql-u username -p
- To clean binary logs older than a specific date.mysql> PURGE BINARY LOGS BEFORE ‘2018
- -12-15 00:00:00′;