Host is not allowed to connect to this MySQL server错误的解决办法

来源:互联网 发布:自学编程网站有哪些 编辑:程序博客网 时间:2024/06/06 01:12

错误描述

我先做了这些工作:服务器用的 Windows Server 2012。配置好服务器上的MySQL。防火墙允许mysqld.exe 。
然后在我自己的电脑上用 workbench 连接服务器上的 MySQL 发现无法连接。提示错误: Host ‘xxx.xxx.xxx.xxx’ is not allowed to connect to this MySQL server 。其中 ‘xxx.xxx.xxx.xxx’ 是我自己的电脑的IP。

解决方法

远程桌面连接到服务器。调用 mysql -u root -p 命令打开客户端,连接数据库。执行如下命令并得到返回结果:

mysql> use mysqlmysql> select t.host from user t where t.user='root';+--------------+|  host        |+--------------+|  localhost   |+--------------+

这个返回结果说明现在 root 用户只允许在服务器的本地登录。
执行如下命令:

update user set host='%' where user='root';

然后重启 MySQL 服务就可以了。
原文地址

0 0
原创粉丝点击