Apr 28, 2025
0
Level 3
Cannot connect to mysql
Hello, I am trying to use laravel inside docker and mysql but I got this
SQLSTATE[HY000] [1045] Access denied for user 'root'@'172.26.0.3' (using password: YES)
I can not even connect to mysql with mysql -u root -p inside docker image
abdullajonov@arch /s/h/W/G/database (main) [1]> docker exec -it mysql8 bash
bash-5.1# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
bash-5.1# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
bash-5.1# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
bash-5.1#
Here's the docker-compose.yml
mysql:
image: mysql:8.0
container_name: mysql8
restart: always
environment:
MYSQL_DATABASE: database
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_ROOT_HOST: '%'
volumes:
- mysql_data:/var/lib/mysql
networks:
- app-network
command: --default-authentication-plugin=caching_sha2_password
and .env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=root
DB_PASSWORD=
how can I fix it?
Please or to participate in this conversation.