I wanna deploy MySQL+PHPMyAdmin. My docker-compose.yml:
version: "3"
services:
db:
image: mysql:5.7
restart: always
container_name: db
volumes:
- ./~mysql:/var/lib/mysql
- ./mysql.cnf:/etc/mysql/conf.d/my.cnf
environment:
MYSQL_DATABASE: "dbtest"
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_ROOT_HOST: "%"
networks:
- db
command: --default-authentication-plugin=mysql_native_password
healthcheck:
test: "mysqladmin ping -h localhost"
interval: 1s
timeout: 1s
retries: 60
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.7
restart: always
container_name: phpmyadmin
ports:
- 8080:80
networks:
- external-net
- db
environment:
PMA_HOST: db
depends_on:
- db
networks:
external-net:
external:
name: external-net
db:
driver: bridge
After some time later I getting subject error. MYSQL_ROOT_HOST don’t helped. When I trying to connect to mysql from db-container:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I really don’t know what to do with this magic… Thx.
5
Answers
I’ve recreated your setup and was just adding some ENV configuration to do the trick, I’ve removed volumes section because there was no problem with it:
docker-compose.yml
Accessing PHPMyadmin with root:rootpasswd works fine.
In Genetal settings of Docker enable daemon without TLS. I think It works.
Docker image
This problem might occur, if the files on your local system were created in a corrupted way or are not correctly accessible by the Docker daemon. This might be due to the following reasons:
C
.--build
process to allow an access toC
on Windows these files might still be corrupted.The solution could be do delete the according local files after the access to Docker has been granted, in your case these are files in
/~mysql
and the filemysql.cnf
.For some reason using "~" before the volume path solves the problem for me.
Change this code to
for MySQL container.
You can pass an extra environment variable when starting the MySQL container MYSQL_ROOT_HOST= this will create a root user with permission to login from given IP address. In case where you want to allow login from any IP you can specify MYSQL_ROOT_HOST=%.
This will work only for a newly created containers.
When spinning new container:
In compose file it would be