码头工人错误 2002 (HY000): 无法连接到"db"上的 MySQL 服务器 (115)



i使用dockerhttps://github.com/markshust/docker-magento。当我一步一步地尝试导入数据库时,我得到了错误2002(HY000(:无法连接到"数据库"上的MySQL服务器(115(我尝试了这个解决方案错误2002(HY000(:Can';t连接到';db';(115(。我的yml文件

## Mark Shust's Docker Configuration for Magento
## (https://github.com/markshust/docker-magento)
##
## Version 41.0.2
## To use SSH, see https://github.com/markshust/docker-magento#ssh
## Linux users, see https://github.com/markshust/docker-magento#linux
## If you changed the default Docker network, you may need to replace
## 172.17.0.1 in this file with the result of:
## docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}'
version: "3"
services:
app:
image: markoshust/magento-nginx:1.18-5
ports:
- "80:8000"
- "443:8443"
volumes: &appvolumes
- ~/.composer:/var/www/.composer:cached
- ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached
- ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached
- appdata:/var/www/html
- sockdata:/sock
- ssldata:/etc/nginx/certs
extra_hosts: &appextrahosts
## M1 Mac support to fix Docker delay, see #566
- "app:172.17.0.1"
- "phpfpm:172.17.0.1"
- "db:172.17.0.1"
- "redis:172.17.0.1"
- "elasticsearch:172.17.0.1"
- "rabbitmq:172.17.0.1"
## Selenium support, replace "magento.test" with URL of your site
- "magento.test:172.17.0.1"
phpfpm:
image: markoshust/magento-php:7.2-fpm
volumes: *appvolumes
env_file: env/phpfpm.env

db:
image: mariadb:10.1
command: mysqld --innodb_force_recovery=6 --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
ports:
- "3306:3306"
env_file: env/db.env
volumes:
- dbdata:/var/lib/mysql

redis:
image: redis:6.0-alpine
ports:
- "6379:6379"
elasticsearch:
image: markoshust/magento-elasticsearch:7.9.3-1
ports:
- "9200:9200"
- "9300:9300"
environment:
- "discovery.type=single-node"
## Set custom heap size to avoid memory errors
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
## Avoid test failures due to small disks
## More info at https://github.com/markshust/docker-magento/issues/488
- "cluster.routing.allocation.disk.threshold_enabled=false"
- "index.blocks.read_only_allow_delete"
rabbitmq:
image: rabbitmq:3.8.22-management-alpine
ports:
- "15672:15672"
- "5672:5672"
volumes:
- rabbitmqdata:/var/lib/rabbitmq
env_file: env/rabbitmq.env
mailcatcher:
image: sj26/mailcatcher
ports:
- "1080:1080"
## Selenium support, uncomment to enable
#selenium:
#  image: selenium/standalone-chrome-debug:3.8.1
#  ports:
#    - "5900:5900"
#  extra_hosts: *appextrahosts
volumes:
appdata:
dbdata:
rabbitmqdata:
sockdata:
ssldata:

请记住,您需要连接到正在运行的docker容器。因此,您可能希望使用TCP而不是Unix套接字。检查docker-ps命令的输出,并查找正在运行的MySQL容器。如果你找到一个,那么使用MySQL命令如下:MySQL-h 127.0.0.1-P<mysql_port>(您将在docker ps输出中找到一个端口(。如果你在docker ps输出中找不到任何正在运行的MySQL容器,那么尝试docker images来找到MySQL镜像名称,并尝试这样的方法来运行它:docker run-d-p 3306:3306 tututum/MySQL,其中";tutum/MySQL";是docker图像中的图像名称。

最新更新