Description:
When I used following command for setting replication 'mysqlreplicate --master=root:admin@<MASTER_IP>:3306 --slave=root:admin@<SLAVE_IP>:3306 --rpl-user=root:admin', observed below issues. (Here note that connection user and replication user is same).
On DB server there is user root@% for connection and replication with all privileges.
Now, when I executed above command from my client machine (not db machine), it created 'root@<SLAVE_IP>' user on master without granting any permissions to it. After that while giving 'replication slave' permission to this user, in get_grants function in common/user.py file, it selects user using 'select current_user()'. For which it gets 'root@%' as return result. Now, as 'root@%' user has 'ALL Privileges' it just exits with true without granting any permission.
After that utility sets replication using 'CHANGE MASTER TO ...' query. And after that tries to start slave using 'START SLAVE' query. But while starting replication, slave tries to connect to master using 'root@<SLAVE_IP>' user. Which has got created by mysqlreplicate with no permissions. Because of which it fails with error message 'COM_REGISTER_FAILED'.
Now, issue here is why new user got created. And if it is getting created then why replication slave is getting executed on current user, rather than getting executed on user which has got created by mysqlreplicate utility.
How to repeat:
1. One client machine and two DB servers. On both db servers there is user as root@% with all privileges.
2. Execute command "mysqlreplicate --master=root:admin@<MASTER_IP>:3306 --slave=root:admin@<SLAVE_IP>:3306 --rpl-user=root:admin'"
Note : My connection user and replication user both are same and I don't have any requirement of having different replication user. Also security is not a concern for me. So I can have root@% user with all privileges.
Suggested fix:
In get_grants function in common/user.py file, rather that fetching user from db server using 'select current_user()' query, pass username of created user to this function. And see if this user has required grants or not. And if required permission is not there assign required permission.