2

I am unable to connect my Sequel Pro to my docker mysql container. I keep getting the following error message:

enter image description here

I have a docker-compose.yml ;

db:
        image: mysql:5.7
        ports: 
            - "33071:3306"
        command: --default-authentication-plugin=mysql_native_password
        environment:
          - MYSQL_ROOT_PASSWORD=root
          - MYSQL_DATABASE=default
        volumes:
            - ./dump:/docker-entrypoint-initdb.d
            - ./db/mysqlconf:/etc/mysql/conf.d
            - ./mysqldata:/var/lib/mysql
        
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - "8677:80"
    links:
      - db    

I have read multiple forum answers on this but none of them helps. The most relevant is this link but this seems to relate to the mysql on the mac as opposed to a docker container. He talks of editing the my.cnf file located in /etc/my.cnf. on Unix/Linux.

However my docker container does not have a my.cnf file.

So I am not sure what to do. I used the following settings for Sequel Pro connection:

Host:     127.0.0.1
Username: root  
Password: root 
Database: (left it blank)
Port:     3306
aryanveer
  • 628
  • 1
  • 6
  • 17
theSeeker
  • 297
  • 4
  • 12

1 Answers1

4

You are mapping port 33071 of your host, to port 3306 of your docker container in your docker-compose file.

ports: 
    - "33071:3306"

But in your Sequel Pro settings mentioned above, you are using port 3306 of your host. That is incorrect.

Solution:

Use the host port that is mapped with docker container i.e 33071

(Ideally you should have kept the port as 3307 in port mapping).

aryanveer
  • 628
  • 1
  • 6
  • 17
  • Why port `3307`? – axiac Aug 19 '20 at 17:05
  • Not necessary, I just mentioned that because it is easier to remember. Well it is choice based. – aryanveer Aug 19 '20 at 17:07
  • Why not `3306`? – axiac Aug 19 '20 at 17:44
  • So if you are using Docker for mysql, there is a chance that user has already installed mysql server on local(which is on port 3306 of localhost always). So to differentiate, a different port can be used. Depends on the use case. – aryanveer Aug 19 '20 at 17:54
  • If one uses Docker for MySQL, the chances are that they do not have the MySQL server installed and cannot or do not want to install it. Otherwise, why would they use MySQL in a Docker container? – axiac Aug 19 '20 at 18:23
  • 1. Requirement of different mysql versions in development. 2. Multiple mysql containers that need to be started simultaneously, so you need different port numbers for them. – aryanveer Aug 19 '20 at 18:29