Connect workbench with mysql container

hi
I want to connect workbench with mysql container but when i test the connection in workbench the connection is failed the mysql is not running
i use this command to ru mysql
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql
what is the problem ?

hello @fatihach ,

I have tried to reproduce this and I can connect.
could you please share your docker version and mysql pod log and error you are getting

below is the log from my test for your reference:

2023-05-07 15:23:19 2023-05-07T14:23:19.253132Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33)  MySQL Community Server - GPL.
2023-05-07 15:23:43 2023-05-07 14:23:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
2023-05-07 15:23:44 2023-05-07 14:23:44+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-05-07 15:23:44 2023-05-07 14:23:44+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.33-1.el8 started.
2023-05-07 15:23:44 '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2023-05-07 15:23:44 2023-05-07T14:23:44.568504Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2023-05-07 15:23:44 2023-05-07T14:23:44.569710Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.33) starting as process 1
2023-05-07 15:23:44 2023-05-07T14:23:44.575015Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-07 15:23:44 2023-05-07T14:23:44.654600Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-07 15:23:44 2023-05-07T14:23:44.752545Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-05-07 15:23:44 2023-05-07T14:23:44.752570Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-05-07 15:23:44 2023-05-07T14:23:44.753760Z 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.
2023-05-07 15:23:44 2023-05-07T14:23:44.763814Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2023-05-07 15:23:44 2023-05-07T14:23:44.763848Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.33'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server

1 Like

thanks for that
I use docker version v4.17
mysql last version
I change the hostname by this 172.17.0.2 (the ip adress of mysql cantainer ) I have this error unable to connect to localhost

could you please try with this host as per the screenshot attached?
that is 127.0.0.1

also please note 172.17.0.2 is an internal docker bridge network.

"Containers": {
            "5143b034c28c66e341bb346bd22250b3e5a621436d58e3ccfb4f70ebc4aa28ee": {
                "Name": "mysql",
                "EndpointID": "79878f87d30e8d8b183112c9f90a1bdf400f099fdb2be9b655e6c6d6aefd43f2",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },

docker exposing the port to localhost

2 Likes

thanks I do that it is work now

1 Like