I have set --replicate-ignore-db=mysql
in MySQL slave, but still it is replicating any users I create on the master.
Is there a way to stop the slave from replicating users?
MySQL
I have set --replicate-ignore-db=mysql
in MySQL slave, but still it is replicating any users I create on the master.
Is there a way to stop the slave from replicating users?
Best Answer
For statement-based replication(the default for mixed binary logging format),
--replicate-ignore-db=foo_db
works only whenfoo_db
is explicitly used as inUSE foo_db
. In aGRANT
orREVOKE
statement,USE mysql
is not executed, as can be seen from the binary log.For row-based replication, if
--replicate-ignore-db=foo_db
, any direct change to a table infoo_db
would not be replicated to the slave. But MySQL always uses statement-based logging for statements that indirectly change the tables ofmysql
database(GRANT
,REVOKE
,SET PASSWORD
,ALTER
,DROP
,CREATE
), regardless of the value ofbinlog_format
.So, to stop replicating any changes in
mysql
database to slave, you can setbinlog-ignore-db=mysql
in your master's configuration file to stop logging any changes inmysql
database. You can also temporarily turn offsql_log_bin
for your session andCREATE
/ALTER
the user before turning the variable back on again.