Sometimes you want to reduce disk usage on certain servers by adjusting the time that binary logs are kept. Also, some installations of MySQL and MariaDB have suffered from a very-hard-to-catch bug where the binary logs end up not getting automatically expired (basically, the expire_logs_days option doesn’t always work effectively).
A workaround can be scripted, but typically the script would specify the exact datetime to which the logs need to be kept. The reference manual and examples all do this too, quite explicitly, noting:
The datetime expression is in the format ‘YYYY-MM-DD hh:mm:ss’.
However, the actual command syntax is phrased as follows:
PURGE { BINARY | MASTER } LOGS { TO ‘log_name’ | BEFORE datetime_expr }
and that indicates much more flexibility in the parser: “datetime_expr” means that you …
[Read more]