I'm setting up a wamp. The docker-compose was working very well until I experience some problems with the phpmyadmin and mysql container. I couldn't connect nor from php or phpmyadmin and usually had this error message : mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
I was able to solve the problem by just connecting entering the shell of the db container docker exec -it db mysql -uroot -p and running this command : ALTER USER 'root' IDENTIFIED WITH mysql_native_password by '123456'; But this kind of boring because I have a partner working on the same project and we have to change working posts a lot so it means rerun docker each time in the development phase so I was wondering what's wrong on my docker-compose...
Here it is :
version: "3.1"
services:
www:
build: .
container_name: app
ports:
- "8001:80"
volumes:
- ~/Desktop/WORK_in_progress/camagru/www/:/var/www/html/
links:
- db
networks:
- default
db:
image: mysql:8.0
container_name: db
restart: always
tty: true
ports:
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
command: --innodb-use-native-aio=0
environment:
MYSQL_DATABASE: CAMAGRU
MYSQL_USER: user
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
volumes:
- ~/Desktop/WORK_in_progress/camagru/dump:/docker-entrypoint-initdb.d
- ~/Desktop/WORK_in_progress/camagru/conf:/etc/mysql/conf.d
- persistent:/var/lib/mysql
networks:
- default
phpmyadmin:
container_name: phpmyadmin
restart: always
tty: true
image: phpmyadmin/phpmyadmin
links:
- db:db
ports:
- 8000:80
environment:
MYSQL_USER: user
MYSQL_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: 123456
volumes:
persistent:
note : I don't use any configurations file, I modified a bit a compose that I found online.
Your command is right, the issue appears because you have defined the command key two times, and the second one is overriding the first one. Instead you should define it only once and like this:
command: --default-authentication-plugin=mysql_native_password --innodb-use-native-aio=0