Skip to content

Instantly share code, notes, and snippets.

@vpnwall-services
Created February 12, 2021 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vpnwall-services/9a14a28e1128f9b8055595151327a747 to your computer and use it in GitHub Desktop.
Save vpnwall-services/9a14a28e1128f9b8055595151327a747 to your computer and use it in GitHub Desktop.
[MYSQL PURGE BINLOG] MySQL Purge binlogs #mysql #purge #delete #binlog

List all binary logs

SHOW BINARY LOGS;

Delete binary logs older than 3 days

PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY);

Drop old tables / rebuild tables

mysql> DELETE tbl_name WHERE id < 100000; -- remove 100K rows
mysql> OPTIMIZE TABLE tbl_name;

Force rebuild after alter statement

mysql> ALTER TABLE tbl_name FORCE;
mysql> ALTER TABLE tbl_name; -- a.k.a "null" rebuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment