在尝试从客户端系统连接远程mysql服务器时,我们经常遇到下面的问题,远程客户端不允许访问这个mysql服务器,如下所示。
# mysql -h 192.168.1.10 -u root -penter 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 -penter 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 27server version: 5.1.69 source distributioncopyright (c) 2000, 2013, oracle and/or its affiliates. all rights reserved.oracle is a registered trademark of oracle corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners.type 'help;' or 'h' for help. type 'c' to clear the current input statement.mysql>
本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注的其他相关栏目教程!!!
以上就是如何允许远程客户端连接mysql服务器的详细内容。