Limit disk used by MySQL binary log files

On a server, the disk was almost full. On checking most of the disk space is used in “/var/lib/mysql” folder, which had many MySQL binary logs.

In the MySQL command prompt, run the command to see all MySQL binary logs

On checking MySQL configuration, I had the line

This limited the binlog file size to 100 MB, when the file size reached 100 MB, the file get rotated.

How long logs are kept is determined by the value of binlog_expire_logs_seconds. The default value for this variable was 2592000, which is approx 30 days.

To make the MySQL bin log expire after 48 hours, add the following to the MySQL configuration file under the [mysqld] directive.

Restart the MySQL server with

On RHEL based servers

After restarting I checked the disk space used by folder “/var/lib/mysql”, it changed to 13 GB, which is much lower than the initial MySQL disk usage.

Disable MySQL binlog

In my.cnf, add

Restart the MySQL server

Back to MySQL

Need help with Linux Server or WordPress? We can help!

Leave a Reply

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