When trying to connect to the remote mysql server from the client system, we often encounter the following problem. The remote client is not allowed to access this mysql server, as shown below.
# mysql -h 192.168.1.10 -u root -p Enter password: [Output] ERROR 1130 (HY000): Host '192.168.1.12' is not allowed to connect to this MySQL server
This problem is because if the client system does not have the permission to connect to the mysql server. By default, mysql server does not allow any remote client connections.
(Related recommendations: MySQL Tutorial)
Allow MySQL client to connect:
Allow the client system to connect to the mysql server . First use ssh to log in to the remote mysql server, and then log in to the mysql server locally. Now use the following command to allow remote clients. For example, if the remote client's IP is 192.168.1.12 and tries to connect through the MySQL root account.
[The following commands need to be run on the mysql server]
# mysql -u root -p Enter password: mysql> GRANT ALL ON *.* to root@'192.168.1.12' IDENTIFIED BY 'new-password'; mysql> FLUSH PRIVILEGES; mysql> quit
A new account has been successfully created in the MySQL server to connect from the specified client system.
Let's try to connect from the client system.
# mysql -h 192.168.1.10 -u root -p [Sample Output] Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 27 Server version: 5.1.69 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !
The above is the detailed content of How to allow remote clients to connect to MySQL server. For more information, please follow other related articles on the PHP Chinese website!