docker
docker copied to clipboard
phpMyAdmin can't connect to mysql - both on same network.
Somewhat new to Docker, so it might be a user error...
After having following several YT tutorials, I cannot get PHPMyAdmin to actually log in--I get the following errors:
- mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known
- mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known
My setup is: Docker with the default Laravel setup. Both 'mysql' and 'phpmyadmin' are in the 'sail' network.
Here's my docker-compose.yml:
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.1/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
- redis
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
phpmyadmin:
depends_on:
- mysql
image: phpmyadmin
environment:
- PMA_HOST = mysql
- PMA_PORT = 3306
networks:
- sail
ports:
- 8080:80
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sail-redis:/data'
networks:
- sail
healthcheck:
test: ["CMD", "redis-cli", "ping"]
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
sail-redis:
driver: local
Apparently setting - PMA_ARBITRARY=1 in the yml and then using 'mysql' during login works...
Apparently setting - PMA_ARBITRARY=1 in the yml and then using 'mysql' during login works...
What about using
environment:
PMA_HOST: mysql
PMA_PORT: 3306
it should work fine
It's not working with PMA_HOST and PMA_PORT.
Having this...
environment:
- PMA_HOST = mysql
- PMA_PORT = 3306
...doesn't work. I get the following errors when trying to log in: mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known
When I use this...
environment:
- PMA_ARBITRARY=1
... I can type 'mysql' into the Server field and it allows me to log in.
Perhaps 'mysql' is not unique enough?
Hi,
This is a bit strange, can you try the format I sent you to be sure this is not the cause of this issue ?
PMA_HOST: mysql
PMA_PORT: 3306
Perhaps 'mysql' is not unique enough?
It's just a name, phpMyAdmin will not complain about it ;)
hey, same problems here, same network, and two syntax try
hey, same problems here, same network, and two syntax try
What is your docker compose file?
i have found the solution, juste remove PMA_PORT: 3306
, only the host is enough
The workaround for me was to use the local address of the docker host 10.10.10.x. Using the hostname would fail... I'll have to work out why the host couldn't resolve.
I'll have to work out why the host couldn't resolve.
What is the host ?
Is it external on the computer name ?
I'll have to work out why the host couldn't resolve.
What is the host ?
Is it external on the computer name ?
Local. I have the db and docker/phpmyadmin running on the same host.