解决MySql报错:1130 - Host 'xxx' is not allowed to connect to this MySQL server的方法

发现问题

使用Navicat连接MySql数据库时,未能成功,提示信息如下图:

这个错误提示已经很明确了,"不允许主机‘desktop-teat9ob‘连接到此mysql服务器",知道问题所在就好解决了。

解决办法

我们远程联接到MySql服务器,打开服务器本地Navicat软件,在查询编辑器中执行下面的SQL语句

#查询允许连接的主机及用户信息
select Host,User,Password from mysql.user;

结果如下图:

从结果中可以看到,MySql只允许使用root用户从localhost,127.0.0.1和::1主机上进行连接,也就是只能从本机连接。

注:::1 是Ipv6地址127.0.0.1的缩写,也就是本机。

我们使用SQL语句将::1改为%,

update mysql.user set `Host` = ‘%‘ where `Host` = ‘::1‘ and User = ‘root‘;

执行结果:

[SQL]
update mysql.user set `Host` = ‘%‘ where `Host` = ‘::1‘ and User = ‘root‘;
受影响的行: 1
时间: 0.000ms

然后查询user表,查看结果:

可以看到,已经将::1改为了%,%表示匹配所有host的主机的,开放此权限,会增加MySql的风险,请根据实际情况而定!

执行下面的SQL,使上面的改动生效,否则仍然联接不上

flush privileges;

执行结果如下:

[SQL]
flush privileges;
受影响的行: 0
时间: 0.003ms

此时,我们再用Navicat连接MySql服务器,提示成功,如下图:

问题解决。

补充

如果你想允许用户root从ip为192.168.0.8的主机连接到MySql服务器,并使用123456作为密码,可以执行下面的SQL语句:

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.0.8‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
#执行下面的语句,使上面的改动生效
FLUSH PRIVILEGES;

如果你想允许用户root从ip为192.168.0.8的主机连接到MySql服务器的testdb数据库,并使用123456作为密码

GRANT ALL PRIVILEGES ON testdb.* TO ‘root‘@‘192.168.0.8‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
#执行下面的语句,使上面的改动生效
FLUSH PRIVILEGES;

解决MySql报错:1130 - Host 'xxx' is not allowed to connect to this MySQL server的方法

原文地址:https://www.cnblogs.com/codecat/p/10729033.html

时间: 2024-07-31 11:19:49

解决MySql报错:1130 - Host 'xxx' is not allowed to connect to this MySQL server的方法的相关文章

1130 - Host XXX is not allowed to connect to this MySQL server。

1.在用Navicat配置远程连接Mysql数据库时遇到如下报错信息,这是由于Mysql配置了不支持远程连接引起的. 2.在安装Mysql数据库的主机上登录root用户: mysql -u root -p 3.依次执行如下命令: use mysql; select host from user where user='root'; 可以看到当前主机配置信息为localhost. 4.将Host设置为通配符% Host列指定了允许用户登录所使用的IP,比如user=root Host=192.16

1130 - Host 'localhost' is not allowed to connect to this MySQL server

打开Win7上的Navicat for MySQL后,连接localhost时,提示错误: 其解决方法是: 打开c:/Program Files/MySQL/MySQL Server 5.5下的my.ini文件,查看是否在在[mysqld]的段中存在: skip-grant-tables . 如果没有,添加即可. 目的是跳过MySQL的访问控制,任何人都可以在控制台以管理员的身份进入MySQL数据库. 注意: 在修改完密码以后要把MySQL服务器停掉重新启动才会生效.其方法是在win7中,打开控

message from server: "Host 'xxx' is not allowed to connect to this MySQL server的解决

解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%" mysql -u root -pvmwaremysql>use mysql;   www.2cto.com mysql>update use

解决服务器连接错误Host ‘XXX’ is not allowed to connect to this MySQL server

这段时间在研究火车头的入库教程,在“配置登陆信息和数据库(mysql)”连接中,出现“服务器连接错误Host 'XXX' is not allowed to connect to this MySQL server”的错误.像这种错误,就是典型的远程权限问题. 问题症结是MySQL 没有开放远程登录的权限.这时要看你的服务器到底用的那种系统,linux或者是Windows,这个解决办法不同.解决的办法就是开启 MySQL 的远程登陆帐号. 有两大步: 1.确定服务器上的防火墙没有阻止 3306

ERROR 1130: Host 'xxxx' is not allowed to connect to this MySQL server

解决方法:1. 改表法.可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%" mysql -uroot -p123456>use mysql;mysql>update user set host = '%' where u

java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect to this MySQL server"

java.sql.SQLException: null,  message from server: "Host 'xxx' is not allowed to connect to this MySQL server": 表示该对象不是远程对象,不能通过该对象远程访问数据 解决: 方案一:改表: use mysql ;select user,host,password from user; update user set host = '%' where user='root'; 方

1130 - Host ‘win7' is not allowed to connect to this mysql server

远程连接自己或别人的mysql时,弹出了提示:“1130 - Host ‘win7' is not allowed to connect to this mysql server”,意思是主机不允许连接到mysql服务器,不允许的原因是连接方没有足够的权限.解决办法有两个: 方法一:1)允许任何用户连接:update user set host='%' where user='root';flush privileges; 2)允许ip 192.168.1.3连接update user set

Host 'XXX' is not allowed to connect to this MySQL server 解决方案/如何开启MySQL的远程帐号

如何开启MySQL的远程帐号-1)首先以 root 帐户登陆 MySQL 在 Windows 主机中点击开始菜单,运行,输入“cmd”,进入控制台,然后cd 进入MySQL 的 bin 目录下,然后输入下面的命令.         > MySQL -uroot -p123456                 (123456 为 root 用户的密码.) 如何开启MySQL的远程帐号-2)创建远程登陆用户并授权        > grant all PRIVILEGES on test_db.

Host 'XXX' is not allowed to connect to this MySQL server 解决方案

一般出现此状况的是说明 'xxx'用户没有权限,那么就需要给用户的赋予权限. 如何开启MySQL的远程帐号-1)首先以 root 帐户登陆 MySQL 在 Windows 主机中点击开始菜单,运行,输入"cmd",进入控制台,然后cd 进入MySQL 的 bin 目录下,然后输入下面的命令. > MySQL -uroot -p123456                 (123456 为 root 用户的密码.) 如何开启MySQL的远程帐号-2)创建远程登陆用户并授权 >