DBAtlas · Database operations atlas

Purge old binary logs (PURGE)

MySQLBinlog & Log

Command

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

What it does

Deletes binary log files older than the given date from disk.

When to use it

When binlogs are filling the disk, to clean up old logs that are no longer needed.

Caution

If a replica still needs a binlog being deleted, replication breaks; first verify with SHOW REPLICA STATUS that all replicas have moved past it. To delete up to a specific file: PURGE BINARY LOGS TO 'mysql-bin.000123'; For automatic cleanup, use the binlog_expire_logs_seconds setting.

Open in DBAtlas →

Related