墨斋记

Good Luck To You!

docker访问本地mysql报错

使用 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.SQLException
   Error Code: 1130
   SQL State: HY000

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

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


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

2、navicat修改

图片.png


图片.png  

发表评论:

Powered By Z-BlogPHP 1.7.3

冀公网安备13019902000834
冀ICP备18019600号-1
Copyright CC Some Rights Reserved.Contact Email:chengyingbo88@163.com