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

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:

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