Managing the binary logs

In this section, managing the binary logs in a replication environment is covered. Basic binary log handling is already covered in Chapter 6, Binary Logging, using the PURGE BINARY LOGS command and expire_logs_days variable.

Using those methods is unsafe in a replication environment because if any one of the slaves has not consumed the binary logs and you have deleted them, the slave will go out of sync and you'll need to rebuild it.

The safe way to delete the binary logs is by checking which binary logs have been read on each slave and deleting them. You can use the mysqlbinlogpurge utility to achieve this.

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.