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.