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?
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:
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:
That said try running:
It might work. If it doesn't then look at another answer!
In MySQL 5.7, if you execute the query from Tom Mac's answer, you will get the following error:
You should query
performance_schema
instead. Run the following: