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.