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

Open my.cnf and add the following lines:

shell> sudo vi /etc/my.cnf[mysqld]binlog_do_db=db1binlog_do_db=db2

The behavior on binlog-do-db changes from statement-based logging to row-based logging just like the --database option in the mysqlbinlog utility.

In statement-based logging, only those statements are written to the binary log where the default database (that is, the one selected by USE) is written to the binary log. You should be very careful while using the binlog-do-db option because it does not work as you might expect when using statement-based logging. Go through the following examples mentioned in the reference manual.

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