Set MySQL to allow remote connection under the CentOS Server

Source: Internet
Author: User
Tags centos server

Set MySQL to allow remote connection under the CentOS Server
1. Go to MySQL and create a new user root. The password is root. Format: grant permission on database name. Table name to user @ login host identified by "User Password ";11. grant select, update, insert, delete on *. * to root@192.168.1.12 identified by "root ";1. Original data table structure11. MySQL & gt; use MySQL;12. Database changed13. MySQL & gt; select host, user, password from user;14. + ----------- + ------ + --------------------------------------------- +15. | host | user | password |16. + ----------- + ------ + --------------------------------------------- +17. | localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |18. + ----------- + ------ + --------------------------------------------- +1. Execution result

1. MySQL> use MySQL;

12. Database changed13. MySQL & gt; select host, user, password from user;14. + -------------- + ------ + --------------------------------------------- +15. | host | user | password |16. + -------------- + ------ + --------------------------------------------- +17. | localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |18. | 192.168.1.12 | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |110. 2 rows in set (0.00 sec) you can see that the root user you just created already exists in the user table. The host field indicates the Host to log on to. The value can be an IP address or a host name. (1) If you want to log on with a local IP address, you can change the Host value to your own Ip address.12. Change the host field value to % to realize MySQL remote connection (authorization), which means that the root user can log on to the MySQL server on any client machine. We recommend that you set the value to % during development.11. update user set host = '%' where user = 'root'; change the permission to all privileges 1. MySQL & gt; use MySQL;12. Database changed13. MySQL & gt; grant all privileges on *. * to root @ '%' identified by "root ";14. Query OK, 0 rows affected (0.00 sec) 5. MySQL & gt; select host, user, password from user;16. + -------------- + ------ + --------------------------------------------- +17. | host | user | password |18. + -------------- + ------ + --------------------------------------------- +19. | localhost | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |110. | 192.168.1.12 | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |111. | % | root | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |112. + -------------- + ------ + --------------------------------------------- +13 rows in set (0.00 sec) so that the machine can remotely access MySQL on the machine with the username root Password root.13. Implement MySQL remote connection (change table method)11. use MySQL;12. update user set host = '%' where user = 'root'; in this way, you can access MySQL through the root user at the far end.

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.