Skip to content

Instantly share code, notes, and snippets.

@dharma017
Created August 20, 2024 08:41
Show Gist options
  • Save dharma017/451354f48aa3ad006ac3e30690b36c79 to your computer and use it in GitHub Desktop.
Save dharma017/451354f48aa3ad006ac3e30690b36c79 to your computer and use it in GitHub Desktop.
Delete MySql Log File
Erase all binary logs before midnight 3 days ago.
PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY) + INTERVAL 0 SECOND;
If you want to have binlog rotated away automatically and keep 3 days worth, simply set this:
mysql> SET GLOBAL expire_logs_days = 3;
then add this to /etc/my.cnf
[mysqld]
expire_logs_days=3
and mysqld will delete them logs for you
Updated way:
touch /etc/mysql/mysql.conf.d/binlog_expiration.cnf
Add following content in binlog_expiration.cnf file
[mysqld]
# Three days: 24*60*60*3
#binlog_expire_logs_seconds=259200
skip-log-bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment