1

I have trouble connecting MySql Workbench with my Symfony 4 project via Docker on Windows 10.

My containers are built correctly and I can access the other two. I am getting my web page on http://localhost:8080/ properly, but it seems that MySQL container is connecting on 172.18.0.1

The error is following: MySQL error

And this on docker ps command. Docker Images

I set my enviroment variables in docker-compose.yml and .env files.

services:
  project_web:
      container_name: project_web
      build: ./scripts/provision/docker/nginx/
      depends_on:
        - "project_php"
      ports:
          - 8080:80
      volumes:
          - .:/var/www/html:cached
  project_php:
      container_name: project_php
      build: ./scripts/provision/docker/php-fpm/
      depends_on:
        - "project_mysql"
      expose:
          - 9000
      volumes:
          - .:/var/www/html:cached
  project_mysql:
      container_name: project_mysql
      image: mysql:5.7
      volumes:
          - ./scripts/provision/docker/mysql/data:/var/lib/mysql:cached
          - .:/var/www/html:cached
      ports:
          - 3307:3306
      environment:
         MYSQL_ALLOW_EMPTY_PASSWORD: yes
         MYSQL_DATABASE: project
         MYSQL_USER: root
         MYSQL_PASSWORD: null
         DATABASE_URL: 'mysql://root:@project_mysql:3306/project'

Also tried to change ip to localhost, no success.

JoniJon
  • 13
  • 1
  • 1
  • 6
  • Would you please try 3308 or 3306 or 3307 port in connection. –  Mar 25 '20 at 10:58
  • Tried them all, still the same. :/ @Dlk – JoniJon Mar 25 '20 at 11:05
  • I think you missing something like ip or port See this https://stackoverflow.com/questions/60125114/error-sqlstatehy000-2002-no-such-file-or-directory/60125274#60125274 please, **Note**: MySQL user name is root on default, please double check if you are trying to connect with correct dB name, username and password. –  Mar 25 '20 at 11:12
  • Thank you for replay! I tried with root (it wont recognize my project_mysql that I defined as image container). I am hopeless @Dlk – JoniJon Mar 25 '20 at 11:25
  • Edit your question and add your compose.yml and connection file into question. I still think you don’t have a dB created with name prosper or a username, what I see in your question is your connection is not correct and I think the link in my comment is your answer. –  Mar 25 '20 at 11:31
  • I created db. I checked via WAMP.. Problem is with parameters as I can not conect via docker image. Also changed parameters on yml file, edited above. @Dlk – JoniJon Mar 25 '20 at 11:55
  • Your yml file is still not correct ports: - 3307:3306 both should be the same and correct port you can check on wamp console, this 8080:80 should be 80:80 and much more mistakes, I am on mobile can’t answer, please compare your docker.composer.yml file with docker.composer.yml file in the link in comment. Step by step. –  Mar 25 '20 at 12:01

1 Answers1

0

I see you're on windows. Try connecting to 127.0.0.1:3306 from Workbench. localhost sometime isn't recognized on Docker for windows.

Basster
  • 310
  • 1
  • 10