MySQL authorization (allowing slave server users to log on to the master server) 1. view the user authorization table
select user,host,password from mysql.user;
2. Set a password for the user
update mysql.user set password=PASSWORD('root') where user='root';flush privileges;
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.129ERROR 1045 (28000): Access denied for 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 *.* to root@192.168.0.130 identified by "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)
You 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