Rumah  >  Artikel  >  pangkalan data  >  如何允许远程客户端连接MySQL服务器

如何允许远程客户端连接MySQL服务器

不言
不言asal
2019-03-18 13:59:132955semak imbas

如何允许远程客户端连接MySQL服务器

在尝试从客户端系统连接远程mysql服务器时,我们经常遇到下面的问题,远程客户端不允许访问这个mysql服务器,如下所示。

# 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

这个问题是因为,如果客户机系统没有连接mysql服务器的权限。默认情况下,mysql服务器不允许任何远程客户端连接。

(相关推荐:MySQL教程

允许MySQL客户端连接:

允许客户端系统连接mysql服务器。先使用ssh登录远程mysql服务器,然后在本地登录mysql服务器。现在使用以下命令来允许远程客户端。例如,如果远程客户端的IP是192.168.1.12,并尝试通过MySQL root帐户进行连接。

[以下命令需要在mysql服务器上运行]

# 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

已在MySQL服务器中成功创建新帐户以从指定的客户端系统进行连接。

让我们尝试从客户端系统连接。

# 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>

本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注php中文网的其他相关栏目教程!!!

Atas ialah kandungan terperinci 如何允许远程客户端连接MySQL服务器. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn