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

Extracting based on the database

Using the --database option, you can filter events of a specific database. If you give this multiple times, only the last option will be considered. This works very well for row-based replication. But for statement-based replication and MIXED, this gives output only when the default database is selected.

The following command extracts events from the employees database:

shell> sudo mysqlbinlog /data/mysql/binlogs/server1.000001 --database=employees > binlog_extract

As explained in the MySQL 8 reference manual, suppose the binary log was created by executing these statements using statement-based-logging:

mysql>INSERT INTO test.t1 (i) VALUES(100);INSERT INTO db2.t2 (j)  VALUES(200);USE test;INSERT INTO test.t1 ...

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