gpt4 book ai didi

mysql - docker-compose中的phpmyadmin

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

我对Laravel项目进行了docker化,并希望在MySQL旁边运行时运行PhpMyAdmin。
我的问题是我无法在PhpMyAdmin页面上登录PhpMyAdmin。
这是错误:mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
这是我的docker-compose.yml文件的内容:

version: '3'
networks:
laravel:

services:
mysql:
image: mysql:5.7.22
container_name: mysql
tty: true
restart: unless-stopped
ports:
- "4506:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
MYSQL_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- mysql
ports:
- 8181:80
environment:
MYSQL_USERNAME: homestead
MYSQL_ROOT_PASSWORD: secret
networks:
- laravel
我想念什么?

最佳答案

您需要指定PMA_HOST环境变量,以告诉phpmyadmin在哪里可以找到mysql服务器(在这种情况下,主机名只是服务名mysql):

version: '3'
networks:
laravel:

services:
mysql:
image: mysql:5.7.22
container_name: mysql
tty: true
restart: unless-stopped
ports:
- "4506:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
MYSQL_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- mysql
ports:
- 8181:80
environment:
PMA_HOST: mysql
MYSQL_USERNAME: homestead
MYSQL_ROOT_PASSWORD: secret
networks:
- laravel

关于mysql - docker-compose中的phpmyadmin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63188441/

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