In master-slave replication we are replicating few DBs on slave server with mysql DB. I created an user on master, unfortunately it's not replicated on slave server.
Replicate_Do_DB: app1,app2,mysql
User creation commands:
GRANT SELECT on *.* to 'user1'@'localhost' identified by 'user1';
GRANT SELECT on *.* to 'user1'@'%' identified by 'user1';
GRANT SELECT on *.* to 'user1'@'10.10.10.10' identified by 'user1';
User account successfully created on master but not replicated on slave.
Why this is happening if mysql db is in replication?
MySQL replication is a process that enables data from one MySQL database server (the master) to be copied automatically to one or more MySQL database servers (the slaves).
Replication relies on three threads per master/slave connection: One is created on the master and Two are created on the slaves. The Slave I/O Thread - When you issue START SLAVE on a slave server, the slave creates this thread which connects to the master and requests a copy of the master's binary log.
Hmm. I'm going to take a punt here and say that you are probably using STATEMENT based replication as opposed to ROW BASED replication and that your MySQL version is 5.1 or above...
You can tell which type you are running by running the following SQL on your slave:
select variable_value
from information_schema.session_variables
where upper(variable_name) = 'BINLOG_FORMAT';
As you have correctly identified privileges are only replicated if the mysql schema is included in replication
However, the "gotcha!" here is the --replicate-do-db option. If you are using statement based replication then you will need to specify the mysql database as your default database before running the grants since:
The effects of this option depend on whether statement-based or row-based replication is in use.
Statement-based replication. Tell the slave SQL thread to restrict replication to statements where the default database (that is, the one selected by USE) is db_name.
That said try running:
USE MYSQL;
GRANT SELECT on *.* to 'user1'@'localhost' identified by 'user1';
GRANT SELECT on *.* to 'user1'@'%' identified by 'user1';
GRANT SELECT on *.* to 'user1'@'10.10.10.10' identified by 'user1';
It might work. If it doesn't then look at another answer!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With