1. view the user authorization table
Select User, Host, passwordFromMySQL.User;
2. Set a password for the user
UpdateMySQL.User SetPassword=Password ('Root')Where User='Root'; FlushPrivileges;
3. log on to MySQL
[Root @ H2 ~]# MySQL-Uroot-Proot
4. log on to the master server (192.168.0.129) on the slave server (192.168.0.130)
[Root @ H2 ~]# MySQL-Uroot-Proot-H192.168.0.129Error1045(28000): Access DeniedFor User 'Root'@'H2'(Using password: Yes)
You can see that you cannot log on now.
5. Authorize the root user on the slave server on the master server to allow the root user on the slave server to access the master server
MySQL> Grant All On *.* ToRoot192.168.0.130IdentifiedBy"Root ";
Allow the root user on 192.168.0.130 (slave server) to access the master server. The password is root.
6. view the permission table
MySQL > Select User , Host, password From MySQL.User ; + -- ------ + --------------- + --------------------------------------------- + | User | Host | Password | + -- ------ + --------------- + --------------------------------------------- + | Root| Localhost | * 81f5e21e35407d884a6cd4a731aebfb6af209e1b | | Root | H1 | | | Root | 127.0 . 0.1 | | | | Localhost | | | | H1 | | | Hive | % | * 6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Hive | Localhost | * 4df1d66463c18d44e3b001a8fb1bbfbea13e27fc | | Myhive | Localhost | * 6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Root | 192.168 . 0.130 | * 81f5e21e35407d884a6cd4a731aebfb6af209e1b | + -- ------ + --------------- + --------------------------------------------- + 9 Rows In Set ( 0.00 Sec)
We can see that the root user on the host 192.168.0.130 has been authorized
7. Now you can log on to the master server again.
[Root @ H2 ~]# MySQL-Uroot-Proot-H192.168.0.129