Expire binary logs

Binary logs consume a lot of space based on the number of writes. Leaving them as-is can fill up the disk in no time. It is essential to clean them up:

  1. Set the expiry of logs using binlog_expire_logs_seconds and expire_logs_days.If you want to set an expiry period in days, set expire_logs_days. For example, if you want to delete all the binary logs that are older than two days, SET @@global.expire_logs_days=2. Setting the value to 0 disables automatic expiry. If you want to have more granularity, you can use the binlog_expire_logs_seconds variable, which sets the binary log expiration period in seconds. The effects of this variable and expire_logs_days are cumulative. For example, if expire_logs_days is 1 and binlog_expire_logs_seconds ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.