gpt4 book ai didi

docker - MySQL-workbench 和 Docker 无法在 '127.0.0.1' 上连接到 MySQL 服务器 (61)

转载 作者:行者123 更新时间:2023-12-02 18:04:47 25 4
gpt4 key购买 nike

Om Mac 我在本地网络上使用 docker,我想使用 MySQL-workbench 访问 mysql,但是在我安装 MySQL-workbench 并尝试连接到数据库后,我收到此错误消息

Can't connect to MySQL server on '127.0.0.1' (61)

img

我试图为 docker 找到解决方案,但没有找到。

docker 检查 pkbook_mysql_1
"NetworkSettings": {
"Bridge": "",
"SandboxID": "cb984bedd303958298621c1571482c7c06a2a326df021902c15a7955b8c26b2c",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3306/tcp": null
},
"SandboxKey": "/var/run/docker/netns/cb984bedd303",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"publiquip_default": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"mysql",
"ee6b2dd46fb8"
],
"NetworkID": "8809726a588595aea20989df3608ae6646f2e64aa928974469df34b52febe7a4",
"EndpointID": "f41cf7f7e42f4921393e13c7db9ce046c784c159ad0ff3c74d45ed788323d4b1",
"Gateway": "172.20.0.1",
"IPAddress": "172.20.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:14:00:04",
"DriverOpts": null
}

docker
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
e34b4dbad1e3 pkbook_joomla "/entrypoint.sh apac…" 4 days ago Up 5 hours 0.0.0.0:80->80/tcp pkbook_joomla_1
ee6b2dd46fb8 mysql:5.6 "docker-entrypoint.s…" 6 days ago Up 5 hours 3306/tcp pkbook_mysql_1
0ccd811b7955 pkbook_gulp "docker-entrypoint.s…" 6 days ago Up 5 hours pkbook_gulp_1

最佳答案

您需要使用 -p opt 选项发布 3306 端口。

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -p 3306:3306 mysql 

关于docker - MySQL-workbench 和 Docker 无法在 '127.0.0.1' 上连接到 MySQL 服务器 (61),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57776759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com