Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rgaicherry opened this issue Mar 17, 2017 · 19 comments
Closed

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

rgaicherry opened this issue Mar 17, 2017 · 19 comments

Comments

@rgaicherry
Copy link

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
Copy link
Author

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
Copy link
Author

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

@xvjianzhe
Copy link

... I used 0.0.0.0:3306 connected successfully!

@namelus
Copy link

namelus commented Sep 18, 2017

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?

@saifulss
Copy link

Same problem here. Docker Toolbox, Win10.

192.168.99.100
3306

Getting same error message as @namelus

@saifulss
Copy link

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.

@jeremylima
Copy link

@saifulss it working for me

@jarkos
Copy link

jarkos commented Jun 15, 2018

That was useful for me -> tutorial

@JaimeRamos99
Copy link

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

@halonsotrejo
Copy link

halonsotrejo commented Sep 13, 2018

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 #95

@ltangvald
Copy link
Collaborator

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

@jweboy
Copy link

jweboy commented Oct 16, 2018

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.

@joelrossol
Copy link

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?

@phansw
Copy link

phansw commented Jan 3, 2019

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'

@gerektoolhy
Copy link

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.

@sauravtom
Copy link

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

@Arxero
Copy link

Arxero commented May 22, 2020

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.

@anisomorphic
Copy link

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!

@rajvirrana
Copy link

rajvirrana commented Jul 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests