Om Mac,我在本地网络上使用docker,我想使用MySQL-workbench访问mysql,但是在安装MySQL-workbench并尝试连接数据库后,出现此错误消息
Can't connect to MySQL server on '127.0.0.1' (61)
我试图为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 ps
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
答案 0 :(得分:0)
您需要使用-p opt选项公开3306端口。
regex
答案 1 :(得分:0)
尝试键入容器名称和端口而不是主机127.0.0.1。 如果它不起作用。
在终端中输入docker ps
。 (如果您在创建容器时未提供名称,则docker将使用随机名称进行命名)。如果容器正在运行,您应该在列表上看到它。
然后检查IP和端口:
docker inspect [CONTAINER-NAME]
并在以下位置找到
:“网络设置”:
"3306/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "33082"
}
],
"33060/tcp": null
},
因此,在这种情况下为0.0.0.0:33082