Reduce the size of binlog in MySQL

2023-04-14 linux

If there are many transactions(insert/update/delete) on the server, MySQL tends to occupy huge space for binlog. In such cases, you can reduce the period to keep the files.

SET GLOBAL binlog_expire_logs_seconds = 259200;
SET PERSIST binlog_expire_logs_seconds = 259200;

Also, they can be removed immedeately by the query.

PURGE BINARY LOGS BEFORE '2023-04-12 00:00:00';

https://askubuntu.com/questions/1322041/how-to-solve-increasing-size-of-mysql-binlog-files-problem