欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

MySQL 数据库修改访问权限,不能使用ip连接mysql问题处理:Host ‘host.docker.internal‘ is not allowed to connect to this ...

发布时间:2025/4/16 数据库 58 豆豆
生活随笔 收集整理的这篇文章主要介绍了 MySQL 数据库修改访问权限,不能使用ip连接mysql问题处理:Host ‘host.docker.internal‘ is not allowed to connect to this ... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

使用 ip 访问 mysql 数据库报错,由于默认配置只允许使用 localhost 访问,我们修改下参数即可。

An error occurred while establishing the connection:Long Message: null, message from server: "Host 'host.docker.internal' is not allowed to connect to this MySQL server"Details:Type: java.sql.SQLExceptionError Code: 1130SQL State: HY000

报错翻译:
空指针,来自服务器的消息:"Host ’ Host .docker.internal’ 不允许连接到 MySQL 服务器"

解决方案:
使用 select user,host from user; 命令查看 root 用户的 host,可以看到默认是 localhost

修改 root 用户的 host 为百分号后就可以用 ip 访问了。
update user set host='%' where user='root';
然后 flush privileges; 使之生效。

喜欢的点个赞❤吧!

总结

以上是生活随笔为你收集整理的MySQL 数据库修改访问权限,不能使用ip连接mysql问题处理:Host ‘host.docker.internal‘ is not allowed to connect to this ...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。