How to do it...

Execute the mysqlbinlogpurge script on any of the servers and specify the master and slave hosts. The script connects to all the slaves and finds out the latest binary log applied. Then it purges the master binary logs until that point. You need a superuser to connect to all slaves:

  1. Connect to any of the servers and execute the mysqlbinlogpurge script:
shell> mysqlbinlogpurge --master=dbadmin:<pass>@master:3306 --slaves=dbadmin:<pass>@slave1:3306,dbadmin:<pass>@slave2:3306
mysql> SHOW BINARY LOGS;+--------------------+-----------+| Log_name           | File_size |+--------------------+-----------+| master-bin.000001  |       177 |~| master-bin.000018  |     47785 || master-bin.000019  |       203 || master-bin.000020  |       203 || master-bin.000021 | 177 ...

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.