Connecting to MySql server running in a Docker Container

I have a little problem, I can't seem to connect to mysql server community edition running inside a docker container.

I can easily connect to mysql server using the cli by using:

docker exec -it mysqlserver mysql -uroot -p

But if I try to connect with any other database connector, like DataGrip or MySql Workbench, I get an access denied.

But I changed nothing in the configuration files. I set ip as localhost, using the default 3306 port that the container exposed. username I keep as root and the password is exactly the same but it still keeps failing.

Am I missing something, not understanding anything properly?

Some help would be greatly appreciated!

Extra info: I am using MacOS, running the container with Docker for Mac and I am using as of this moment the latest MySql database version.

1 answer

  • answered 2018-01-11 19:42 Kilian

    your container doesn't contain other connectors, try to publish port when you run your container with docker run --name mysql -p 127.0.0.1:3306:3306 .... to link port. And you can connect you to the container with your local cli. Try this doc