mysql数据库连接报错:is not allowed to connect to this mysql server

2023年11月1日08:09:20 发表评论 912 views

is not allowed to connect to this MySQL server

 

服务器上面安装的mysql数据库在本地连接的时候报错:is not allowed to connect to this MySQL server

mysql数据库连接报错:is not allowed to connect to this mysql server

 

出现这种情况的原因是因为:

mysql数据库只允许自身所在的本机器连接,不允许远程连接。

 

解决:

在mysql所在服务器上面登录进mysql数据库中:

mysql -u root -p

进入到mysql数据库中:

use mysql;
 
select host from user where user='root';

mysql数据库连接报错:is not allowed to connect to this mysql server

可以看到 我们执行查询语句得到的数据结果中 host 的值是 localhost

 

我们执行update语句把权限进行修改

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

然后 刷新配置

flush privileges;

mysql数据库连接报错:is not allowed to connect to this mysql server

如图所示 可以看到已经修改成功

 

然后我们再次进行连接

mysql数据库连接报错:is not allowed to connect to this mysql server

 


欢迎来到菜鸟头头的个人博客
本文章百度已收录,若发现本站有任何侵犯您利益的内容,请及时邮件或留言联系,我会第一时间删除所有相关内容。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: