Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL replication: temporarily prevent specific SQL statements replicating to the slaves?

I want to connect and execute one (or sometimes several) SQL statements, and NOT have those replicated to the slaves.

I have no replicate-do or replicate-ignore configs, so I can't use some non-replicated database to send the commands from. And I know about:

set global sql_slave_skip_counter = 1

But that's on the slave. I'd like to be able to run a similar command on the master and have the following N commands not sent out to the slaves (which I guess means not logged in the binlogs, either).

like image 643
Nautical Avatar asked Dec 10 '08 06:12

Nautical


1 Answers

SET sql_log_bin=0 is what you're looking for. Requires SUPER priv., and will turn off logging of commands from your session until you set it back to 1. See http://dev.mysql.com/doc/refman/5.0/en/server-session-variables.html#sysvar_sql_log_bin

SET sql_log_bin=0;
UPDATE ... ;
INSERT ... ;
DELETE ... ;
SET sql_log_bin=1 ;
like image 65
derobert Avatar answered Sep 25 '22 17:09

derobert