Host 'xxx' is not allowed to connect to this MySQL server.

              mysql开启远程连接

今天在服务器安装了mysql,准备用mysqlguitools远程登录的时候出错,提示:Host ‘xxx‘ is not allowed to connect to this MySQL server。网上找了一些资料,是mysql未开启mysql远程访问权限导致。

记录解决方案供以后参考。:

1.登录到mysql:  mysql -uroot -ppwd

2.查看user表:

mysql> use mysql
Database changed
mysql> select host,user,password from user;
+------+------+-------------------------------------------+
| host | user | password |
+------+------+-------------------------------------------+
| localhost    | root | *826960FA9CC8A87953B3156951F3634A80BF9853 |
+------+------+-------------------------------------------+
1 row in set (0.00 sec)

表中host、user字段标识了可以访问数据库的主机和用户。例如上面的数据就表示只能本地主机通过root用户访问。原来如此,难怪远程连接死活连不上。

为了让数据库支持远程主机访问,有两种方法可以开启远程访问功能。

第一种(改表法):

修改host字段的值,将localhost修改成需要远程连接数据库的ip地址。或者直接修改成%。修改成%表示,所有主机都可以通过root用户访问数据库。为了方便,我直接修改成%。命令:mysql> update user set host = ‘%‘ where user = ‘root‘;

再次查看user表

+------+------+-------------------------------------------+
| host | user | password |
+------+------+-------------------------------------------+
| % | root | *826960FA9CC8A87953B3156951F3634A80BF9853 |
+------+------+-------------------------------------------+
1 row in set (0.00 sec)

修改成功,输入命令mysql> FLUSH PRIVILEGES; 回车使刚才的修改生效,再次远程连接数据库成功。

第二种(授权法):

例如,你想root使用mypassword从任何主机连接到mysql服务器的话。 
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码 
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.1.3‘ IDENTIFIED BY 
‘mypassword‘ WITH GRANT OPTION;

输入命令mysql> FLUSH PRIVILEGES; 回车使刚才的修改生效,再次远程连接数据库成功。bingo.

别忘记最后的FLUSH PRIVILEGES; 刷新先前的修改。

Host 'xxx' is not allowed to connect to this MySQL server.

时间: 2024-08-24 15:01:36

Host 'xxx' is not allowed to connect to this MySQL server.的相关文章

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的远程帐号

如何开启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)创建远程登陆用户并授权 >

解决服务器连接错误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

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'; 方

解决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只允许使用r

linux启动项目提示java.net.ConnectException: 拒绝连接 (Connection refused)或提示Host XXX is not allowed to connect to this MySQL server。

这是由于Mysql配置了不支持远程连接引起的. 1.在安装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.168.1.1.这里的意思就是说root用户只能通过192.168.1.1

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

mysql 1130 ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server

mysql -u root -p  mysql;use mysql;  mysql;select 'host' from user where user='root';  mysql;update user set host = '%' where user ='root';  mysql;flush privileges; mysql 1130 ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL se