Getting ready

Execute a few statements using various binary formats. When you set the binlog_format at GLOBAL level, you have to disconnect and reconnect to get the changes. If you want to be connected, set at SESSION level.

Change to statement-based replication (SBR):

mysql> SET @@GLOBAL.BINLOG_FORMAT='STATEMENT';Query OK, 0 rows affected (0.00 sec)

Update a few rows:

mysql> BEGIN;Query OK, 0 rows affected (0.00 sec)mysql> UPDATE salaries SET salary=salary*2 WHERE emp_no<10002;Query OK, 18 rows affected (0.00 sec)Rows matched: 18  Changed: 18  Warnings: 0mysql> COMMIT;Query OK, 0 rows affected (0.00 sec)

Change to row-based replication (RBR):

mysql> SET @@GLOBAL.BINLOG_FORMAT='ROW';Query OK, 0 rows affected (0.00 sec)

Update a few rows:

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.