// mysql · wal, redo & durability

binlog_expire_logs_seconds

Age after which binary log files are purged automatically.

Default
2592000 (30 days)
Range
0 to 4294967295 seconds (0 disables purging)
Restart needed
No
Default checked on
MySQL 8.4 LTS

What it does

Purging happens at startup and when the binary log rotates.

Default value

2592000 (30 days). 30 days since MySQL 8.0 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'binlog_expire_logs_seconds';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'binlog_expire_logs_seconds';

Change it

SET GLOBAL binlog_expire_logs_seconds = 604800;    -- until the next restart
SET PERSIST binlog_expire_logs_seconds = 604800;   -- now and after restarts

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When to change it

Shorten it when binlogs fill the disk and backups plus replicas do not need 30 days; lengthen it to cover your point-in-time recovery window.

What can go wrong

A replica that falls further behind than the retention can no longer catch up and must be rebuilt.

Questions about binlog_expire_logs_seconds

What is the default value of binlog_expire_logs_seconds in MySQL?

2592000 (30 days). 30 days since MySQL 8.0 (MySQL 8.4).

Does changing binlog_expire_logs_seconds require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When should I change binlog_expire_logs_seconds?

Shorten it when binlogs fill the disk and backups plus replicas do not need 30 days; lengthen it to cover your point-in-time recovery window.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check binlog_expire_logs_seconds on your own server

SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.