Nasty MySQL flaw - the binary logs time bomb!

Hmmm.... Not very nice this one.

OK - so we switch to using my-huge.cnf or my-large.cnf. On current MySQL - Debian Jessie - this changes a couple of settings.

One - it turns on binary logging by setting:

log-bin=mysql-bin

in the cnf file.

BUT - IT DOES NOT SET UP LOG ROTATION!

So, the log files will get created - and more and more will be created - until no space is left.

Fairly easy to fix.

In the my.cnf file add a:

expire_logs_days        = 1

then restart MySQL. This should set the log files to be deleted safely after one day - and the restart will carry out a purge of the current binary log files. (I also like to manually restart to check it restarts OK - i.e. to check that I've edited my.cnf correctly).

Also - on my system it cleaned out approx 140GB in a couple of seconds. Obviously, the following commands were carried out after editing my.cnf.

root@server:~# cd /var/lib/mysql/
root@server:/var/lib/mysql# du -sh
153G .
root@server:/var/lib/mysql# /etc/init.d/mysql restart
Restarting mysql (via systemctl): mysql.service.
root@server:/var/lib/mysql# du -sh
9.6G .