O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required