MySQL authorization (allow slave server users to log on to the master server)

Source: Internet
Author: User

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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.