Answer the question
In order to leave comments, you need to log in
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused?
Hello!
Forces, no, the second time I encounter a similar problem.
Previously, it was solved by connecting to the container.
Creation of a new user.
But now nothing helps!
At the moment I can connect in the container like this:
mysql -uroot -ppkRkEzUDdqOEFXL1pmNkcyQ2RL
.env
DB_DRIVER=pdo_mysql
DB_HOST=127.0.0.1 #or localhost
DB_PORT=3307
DB_DATABASE=gorodbrand
DB_USERNAME=root
DB_PASSWORD=pkRkEzUDdqOEFXL1pmNkcyQ2RL
version: "3.1"
services:
# Php application
app:
container_name: gorodbrand.app
restart: on-failure
build: .
volumes:
- .:/www
- ./docker/php/log:/var/log
depends_on:
- db
links:
- db
# Database
db:
image: percona:latest
container_name: gorodbrand.db
restart: always
volumes:
- ./docker/mysql/log:/var/log/mysql
- ./docker/mysql/conf.d:/etc/mysql/conf.d
ports:
- 3307:3306
expose:
- 3306
environment:
- MYSQL_ROOT_PASSWORD=pkRkEzUDdqOEFXL1pmNkcyQ2RL
- MYSQL_DATABASE=gorodbrand
Answer the question
In order to leave comments, you need to log in
As far as I understand, two things need to be corrected:
1) in docker-compose
ports:
- 3306 :3306
2) .env
DB_DRIVER=pdo_mysql
DB_HOST= db
DB_PORT= 3306
DB_DATABASE=gorodbrand
DB_USERNAME=root
DB_PASSWORD=pkRkEzUDdqOEFXL1pmNkcyQ2RL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question