Home > Database > Mysql Tutorial > How to allow remote clients to connect to MySQL server

How to allow remote clients to connect to MySQL server

不言
Release: 2019-03-18 13:59:13
Original
3046 people have browsed it

How to allow remote clients to connect to MySQL server

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
Copy after login

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
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template