I
I
Igor2019-09-10 04:21:12
Percona
Igor, 2019-09-10 04:21:12

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
5d76fb2811d12996170645.png
.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

I get an error
An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2019-09-10
@IgorPI

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 question

Ask a Question

731 491 924 answers to any question