I recently dug into the wonderful world of MySQL binlogs! Here a few learnings.

Binlogs (binary logs) are log files that record everything your MySQL server does. They’re used for replication or data recovery. Nice to have, but not necessary unless they’re a defined part of your data recovery strategy.

In MySQL 8, binlogs are enabled by default with 30-day retention. Which can lead to many GiB-sized files.

This retention period can be adjusted like this (7-day retention being set here):

SET GLOBAL binlog_expire_logs_seconds = 604800;

If you happen to find lots of unneeded logs, you can set this value and accelerate the purge of excess logs (after a database backup, of course) like this:

PURGE BINARY LOGS BEFORE NOW() - INTERVAL 7 DAY;

binlogs docs