首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >MySQL 数据库修改访问权限,不能使用ip连接mysql问题处理:Host ‘host.docker.internal‘ is not allowed to connect to this ...

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

作者头像
小蓝枣
发布于 2022-04-01 10:11:22
发布于 2022-04-01 10:11:22
3.5K0
举报

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

代码语言:javascript
复制
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.SQLException
   Error Code: 1130
   SQL 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; 使之生效。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档