mysql:logs:binary:purge:interval
This command is used to purge (delete) binary logs in MySQL that are older than a specified interval.
Let's break down the command step by step:
-
mysql
: This is the command-line tool to communicate with the MySQL database server. -
--execute
: This option is used to specify the SQL statement that should be executed. -
\"PURGE BINARY LOGS BEFORE NOW() - INTERVAL ${interval_in_days} DAY\"
: This is the SQL statement that is being executed. It uses thePURGE BINARY LOGS
command to remove binary logs.
The SQL statement has two main parts:
-
NOW() - INTERVAL ${interval_in_days} DAY
: This calculates the date and time that is the specified number of days before the current date and time. The${interval_in_days}
is a placeholder for the actual number of days, which can be supplied as a parameter when executing the command. -
PURGE BINARY LOGS BEFORE
: This is the command to delete binary logs that are older than the specified date and time.
When you run this command, it connects to the MySQL database server, executes the specified SQL statement (PURGE BINARY LOGS BEFORE NOW() - INTERVAL ${interval_in_days} DAY
), and purges the binary logs that are older than the specified interval.