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

Source: Internet
Author: User

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

 

 

Related Article

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.