Skip to content

Instantly share code, notes, and snippets.

@m4tlch
Created September 9, 2022 23:31
Show Gist options
  • Save m4tlch/23714e89f26d88e1acae2d7d999e46a8 to your computer and use it in GitHub Desktop.
Save m4tlch/23714e89f26d88e1acae2d7d999e46a8 to your computer and use it in GitHub Desktop.

Revisions

  1. m4tlch created this gist Sep 9, 2022.
    20 changes: 20 additions & 0 deletions Purge Binlogs for MySql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    https://askubuntu.com/a/1390848

    With MySQL8, they have turned on binary logging by default and the default purge (expiry/deletion) of binary logs is set to 30days.

    Once you are in your SSH and in mysql, you can use the below commands

    To show binary logs

    mysql> SHOW BINARY LOGS;
    To Purge binary logs manually until some point

    mysql> PURGE BINARY LOGS TO 'binlog.000142';
    Change automatic default purge expiry from 30days (deafault) to 3days

    mysql> SET GLOBAL binlog_expire_logs_seconds = (60*60*24*3);
    Query OK, 0 rows affected (0.00 sec)

    mysql> SET PERSIST binlog_expire_logs_seconds = (60*60*24*3);
    Query OK, 0 rows affected (0.01 sec)
    The above value is in seconds, i.e. 3 days in seconds = (60 seconds x 60 minutes x 24 hours x 3 days)