PURGE BINARY LOGS TO'binlogname';These will clear all binary logs before the binlog or timestamp you just specified.
PURGE BINARY LOGS BEFORE 'datetimestamp';
For example, if you run
PURGE BINARY LOGS TO'mysql-bin.000223';
this will erase all binary logs before 'mysql-bin.000223'.
If you run
PURGE BINARY LOGS BEFORE DATE(NOW()- INTERVAL 3 DAY)+ INTERVAL 0 SECOND;
this will erase all binary logs before midnight 3 days ago.
If you want to have binlog rotated away automatically and keep 3 days woth, simply set this:
mysql>SET GLOBAL expire_logs_days =3;then add this to
/etc/my.cnf