Connection to mysql fails

I’m running metabase and MySQL in seperate docker containers, both connecting to the same bridge.

I can ping the MySQL container from the metabase container. However, when I try to connect to MySQL from the metabase interface, I am getting the following error:

"unexpected end of stream, read 0 bytes from 4 (socket was closed by server)".

Here is my config:

  • Windows 10
  • Metabase version v0.36.4 (196c1f6 release-0.36.x)
  • 8.0.21 MySQL Community Server - GPL

And my docker network configuration:

```
[
    {
        "Name": "mysql-metabase-net",
        "Id": "bbe21c1873049a3ce0aee6f2e8b2cd3ba5c443cc655d685368f342b42e9d6e98",
        "Created": "2020-09-07T05:18:19.355990708Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "7c1dfaee4a8783aae6afccbbc1970d3fb971645a972c2484e67125b7aba027bc": {
                "Name": "my-container",
                "EndpointID": "7ee6b1f4b850f2a9389fa6cda311eb19e28016890eafd7659255d2fab9b7a38b",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            },
            "cc261fe878298ec8199a700351195901a65f3575d395971a6f5268e9a0b9d93f": {
                "Name": "metabase",
                "EndpointID": "0c3541adc8d42c57a14c7d3f465111c2734718734432df5a61ee676628ef79b2",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

```

Am I doing something wrong? Any idea what the issue could be?

Thanks for your help.

Jeremy

Hi @JChamboredon
Did you try adding the recommendation?
09-08 03:50:22 INFO driver.mysql :: You may need to add trustServerCertificate=true to the additional connection options to connect with SSL.
Have you checked the MySQL log for more details on why it’s failing?

Hi @flamber,

I did try this but I’m not too sure if I did it properly. I was not even connecting with SSL in the first place.

Tried this again but got the same message.

I have not checked the MySQL logs, not exactly sure where to find them as it’s running in a docker container.

@JChamboredon
I would generally not recommend using Docker for production if you are not familiar with it.
You get logs from Docker with docker logs

@flamber
It does not look like mysql has logged anything from any metabase connection intent:

2020-09-09 04:15:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-09-09 04:15:58+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-09-09 04:15:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-09-09T04:15:58.808931Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21) starting as process 1
2020-09-09T04:15:58.830196Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-09-09T04:15:59.340815Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-09-09T04:15:59.641896Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2020-09-09T04:15:59.685600Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2020-09-09T04:15:59.701888Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2020-09-09T04:15:59.790717Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-09-09T04:15:59.791192Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-09-09T04:15:59.806146Z 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.
2020-09-09T04:15:59.870405Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

@JChamboredon Then enable debug logging on MySQL, so you get more information. If you don’t know how to do that, then ask in a Docker specific forum or stackoverflow.com since it’s not related to Metabase.
The error Metabase receives from the driver says that the server closed the connection.

@flamber
Thanks I can remember reading about this, I will check it out. It also looked like I had my ports messed up, which I managed to fix. Now I’m getting the following error:

RSA public key is not available client side (option serverRsaPublicKeyFile not set)

I’m assuming this is something I need to set on mysql, right?

@JChamboredon Well, that’s totally different - read this:
https://github.com/metabase/metabase/issues/12545

Thanks, already reading it after some googling :upside_down_face:

OK I managed to fix this by enabling SSL and adding trustServerCertificate=true to the additional connection options as suggested in the metabase log. Thanks!