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 

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

6 Comments

Why port 3307?
Not necessary, I just mentioned that because it is easier to remember. Well it is choice based.
Why not 3306?
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.
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?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.