mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Can't connect to mysql container from MySQL Workbench (Windows 10)

Open rgaicherry opened this issue 9 years ago • 19 comments

Need help to connect to mysql container from MySQL Workbench (Windows 10). Here are the steps I took:

  1. Installed Docker for Windows 10.

  2. Downloaded mysql instance via command:

     docker run --name mysql_qa -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql
    
  3. Verified that mysql container is running (checked via "docker ps"):

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c1616f7623d4 mysql "docker-entrypoint..." 18 hours ago Up 24 minutes 0.0.0.0:3306->3306/tcp mysql_qa

  1. Got he IP address of mysql container via "docker inspect mysql_qa":

    "IPAddress": "172.17.0.2"

  2. Verify mysql container' status via "docker logs mysql_qa" and got the following:

2017-03-17T14:47:57.495536Z 0 [Note] Event Scheduler: Loaded 0 events 2017-03-17T14:47:57.495719Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2017-03-17T14:47:57.495732Z 0 [Note] Beginning of list of non-natively partitioned tables 2017-03-17T14:47:57.510976Z 0 [Note] End of list of non-natively partitioned tables 2017-03-17T14:47:57.511134Z 0 [Note] mysqld: ready for connections. Version: '5.7.17' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)

  1. Installed MySQL Workbench for Windows 64bit.

  2. Inside MySQL Workbench, I tried to connect to mysql container using IP address 172.17.0.2 and port 3306, it failed. I also tried to connect to 192.168.99.100 and port 3306. It failed too.

Any help will be greatly appreciated. Thanks ahead.

rgaicherry avatar Mar 17 '17 15:03 rgaicherry

Here's my "docker version": Client: Version: 17.03.0-ce API version: 1.26 Go version: go1.7.5 Git commit: 60ccb22 Built: Thu Feb 23 10:40:59 2017 OS/Arch: windows/amd64

Server: Version: 17.03.0-ce API version: 1.26 (minimum version 1.12) Go version: go1.7.5 Git commit: 3a232c8 Built: Tue Feb 28 07:52:04 2017 OS/Arch: linux/amd64 Experimental: true

rgaicherry avatar Mar 17 '17 15:03 rgaicherry

Problem solved: using hostname as localhost / port 3306, connected successfully. Thx.

rgaicherry avatar Mar 17 '17 15:03 rgaicherry

... I used 0.0.0.0:3306 connected successfully!

xvjianzhe avatar Sep 11 '17 05:09 xvjianzhe

I have Hostname: 192.168.99.100 Port: 3306

When I click test connection the error dialog reads

Host '192.168.99.1' is not allowed to connect to this MySQL server.

Additionally - my environment is Win7 Home with the latest Docker Toolbox.

Any suggestions?

namelus avatar Sep 18 '17 15:09 namelus

Same problem here. Docker Toolbox, Win10.

192.168.99.100 3306

Getting same error message as @namelus

saifulss avatar Dec 14 '17 06:12 saifulss

Fixed it.

I had to create a user which has origin set as '%' as such:

CREATE USER 'monty'@'%' IDENTIFIED BY 'secret';

At the MySQL Workbench connection, use this new user. Worked.

saifulss avatar Dec 14 '17 06:12 saifulss

@saifulss it working for me

jeremylima avatar Jan 09 '18 20:01 jeremylima

That was useful for me -> tutorial

jarkos avatar Jun 15 '18 15:06 jarkos

i have created a docker container with an image of mysql 5.7 but i do not know how to connect from workbench to the database that is in that container... helppp

JaimeRamos99 avatar Jun 16 '18 02:06 JaimeRamos99

It looks mysql interpreting the -p as an argument, I just had to move the argument:

docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest

copy from https://github.com/docker-library/mysql/issues/95

halonsotrejo avatar Sep 13 '18 15:09 halonsotrejo

Anything after the image name is passed as arguments to the server. Arguments for docker have to be before it

ltangvald avatar Sep 14 '18 05:09 ltangvald

Fixed it.

I had to create a user which has origin set as '%' as such:

CREATE USER 'monty'@'%' IDENTIFIED BY 'secret';

At the MySQL Workbench connection, use this new user. Worked.

@saifulss it's also working for me.thx.

jweboy avatar Oct 16 '18 14:10 jweboy

Fixed it.

I had to create a user which has origin set as '%' as such:

CREATE USER 'monty'@'%' IDENTIFIED BY 'secret';

At the MySQL Workbench connection, use this new user. Worked.

This allowed me to log in to Mysql via "tableplus"... but I am unable to create new tables from within that tool. I get the error message

Access denied for user 'admin'@'%' to database 'test'

Any ideas?

joelrossol avatar Dec 22 '18 23:12 joelrossol

Fixed it. I had to create a user which has origin set as '%' as such: CREATE USER 'monty'@'%' IDENTIFIED BY 'secret'; At the MySQL Workbench connection, use this new user. Worked.

This allowed me to log in to Mysql via "tableplus"... but I am unable to create new tables from within that tool. I get the error message

Access denied for user 'admin'@'%' to database 'test'

Any ideas?

You probably have to grant the right permissions. e.g.

GRANT ALL PRIVILEGES ON <database_name>.* TO 'username'@'%' IDENTIFIED BY 'password'

phansw avatar Jan 03 '19 05:01 phansw

You probably have to grant the right permissions. e.g. GRANT ALL PRIVILEGES ON <database_name>.* TO 'username'@'%' IDENTIFIED BY 'password'

This syntax did not work for me. This worked instead:

GRANT ALL PRIVILEGES ON <database_name>.* TO 'username'@'%';

database_name can be * to grant access to all databases.

gerektoolhy avatar Jan 09 '19 21:01 gerektoolhy

This SO answer worked for me https://stackoverflow.com/a/51437525/10034557

sauravtom avatar Jan 18 '19 04:01 sauravtom

Just worth noting that if you already have running MySQL or MariaDB on port 3306 it wouldn't work, go to your windows services, and disabled it.

Arxero avatar May 22 '20 10:05 Arxero

What worked for me was recreating the container with the -p 3306:3306 flag, it popped up the windows firewall dialog and once I clicked "allow" I was able to connect with 'localhost' thru MySQL workbench and PyCharm. Hope this helps!

anisomorphic avatar Jun 26 '20 07:06 anisomorphic

in SSL Tab set 'Use SSL' to 'No'

rajvirrana avatar Jul 08 '22 09:07 rajvirrana