Thamiar
Thamiar

Reputation: 610

Connect to mysql container using Mysql Workbench

I succesfully created docker with commad

docker run --name my-db -d -p 3306:3306 -v /e/DockerData/mysql:/var/lib/mysql -e="MYSQL_ROOT_PASSWORD=null" mysql

Just to test if I would have to type String 'null' as password ;) It worked. Using

docker exec -it my-db bash

and then

mysql -p

i could connect to mysql command line. However when I tried to run it via workbench it did not work. I deleted both workbench and whole MySql stuff from my computer, as it could couse problems. And then I reinstalled only Workbench. It did not help.

I was connecting via urls 0.0.0.0:3306, localhost:3306 and 192.168.99.100:3306 non of them worked. (I am working on DockerToolbox, because of Windows 10 Home). When I Try to connect I get this exception: enter image description here

What is also interesting is that if I stop and delete the image, and create container using:

docker run --name my-db -p 3306:3306 -v /e/DockerData/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=testDB -d mysql

I still need to use password 'null' when entering docker exec -it my-db bash and then mysql -p
and I have no idea what is going one. enter image description here enter image description here

Anyone have any idea? ​Maybe catches? Or it is stored somewhere? I removed image, pulled it again and it did not helped. Typing null as password helps, admin does not mach.

Logs:

$ docker logs -f 132646ed8949
2018-06-13T17:53:31.961392Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2018-06-13T17:53:31.961823Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 1
mbind: Operation not permitted
2018-06-13T17:53:32.728416Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-06-13T17:53:32.747107Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2018-06-13T17:53:32.782912Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.783958Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.784429Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.785231Z 0 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.786186Z 0 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.786320Z 0 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.786380Z 0 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.798621Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.799734Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-06-13T17:53:32.811232Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

​ ​I removed Container and Image. Pulled it one more time, run docker Command. First try was password admin second null… Maybe it is because the first command I run had " " -e="MYSQL_ROOT_PASSWORD=null" ?

enter image description here

Upvotes: 2

Views: 7690

Answers (2)

Thamiar
Thamiar

Reputation: 610

I found the solution, and I hope it will help someone:

It that MySQL changing their authentication style after relese 8.0 Running older versions solve the problem:

docker run --name my-db -p 3306:3306 -v
/e/DockerData/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=admin -e
MYSQL_DATABASE=testDB -d mysql:5.7.22

Upvotes: 3

Sergiu
Sergiu

Reputation: 3185

Your DB it isn't listening on any of the addresses you've provided, it is listening on the container name as from the picture you have posted.

You either can add the container hostname into your hosts files, such as: 1326xxxxxx 192.168.99.100 (which i presume it is the host ip address that you run the container on) or you could pass --hostname mydb at the runtime of the container and add that into your hosts file.

Upvotes: 0

Related Questions