All pages
Powered by GitBook
1 of 1

Loading...

PURGE BINARY LOGS

Deletes binary log files from the server. Removes logs based on a specific filename or date timestamp to reclaim disk space and manage storage.

Syntax

Description

The PURGE BINARY LOGS statement deletes all the files listed in the log index file prior to the specified log file name ordate. BINARY and MASTER are synonyms.Deleted log files also are removed from the list recorded in the index file, sothat the given log file becomes the first in the list.

The datetime expression is in the format 'YYYY-MM-DD hh:mm:ss'.

If a replica is active but has yet to read from a binary log file you attempt to delete, the statement will fail with an error. However, if the replica is not connected and has yet to read from a log file you delete, the file will be deleted, but the replica will be unable to continue replicating once it connects again.

This statement has no effect if the server was not started with the option to enable binary logging.

To list the binary log files on the server, use . To see which files they are reading, use . You can only delete the files that are older than the oldest file that is used by the slaves.

To list the binary log files on the server, use . To see which files they are reading, use . You can only delete the files that are older than the oldest file that is used by the slaves.

To delete all binary log files, use .To move to a new log file (for example if you want to remove the current log file), use before you execute PURGE LOGS.

If the server system variable is not set to 0, the server automatically deletes binary log files after the given number of days. From MariaDB 10.6, the variable allows more precise control over binlog deletion, and takes precedence if both are non-zero.

Requires the privilege.

Requires the SUPER privilege.

Examples

See Also

  • .

This page is licensed: GPLv2, originally from

PURGE { BINARY | MASTER } LOGS
    { TO 'log_name' | BEFORE datetime_expr }
binary log
--log-bin
SHOW BINARY LOGS
SHOW REPLICA STATUS
SHOW BINARY LOGS
SHOW SLAVE STATUS
RESET MASTER
FLUSH LOGS
expire_logs_days
binlog_expire_logs_seconds
BINLOG ADMIN
Using and Maintaining the Binary Log
FLUSH LOGS
fill_help_tables.sql
PURGE BINARY LOGS TO 'mariadb-bin.000063';
PURGE BINARY LOGS BEFORE '2013-04-21';
PURGE BINARY LOGS BEFORE '2013-04-22 09:55:22';