当前位置:Gxlcms > 数据库问题 > Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

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

时间:2021-07-01 10:21:17 帮助过:18人阅读

技术图片

1、感觉是服务器3306端口没有开放导致,查看:

技术图片

 已经开放了3306端口号,排除端口的问题。

2、后来查看官网得知:root用户拒绝远程连接导致

我们用root用户本地登录mysql,查看user表

use mysql;

技术图片

select * from user where User = root \G

“\G”是为了格式化显示,方便阅读。

技术图片

Host:localhost 表示只允许本地连接

技术图片

 上图中给出了user表不同的Host字段的连接权限,得知我们要远程连接需要Host字段为“%”

3、所以我们需要新建立一个用户,并且是Host字段为“%”

 

CREATE USER ‘crelle@% IDENTIFIED BY 123456;

GRANT ALL PRIVILEGES ON *.* TO crelle@% WITH GRANT OPTION;

FLUSH PRIVILEGES;

 

技术图片

 

 4、再次连接成功

技术图片

 

 完毕!

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

标签:导致   image   没有   sel   端口   png   阅读   远程   col   

人气教程排行