Can't connect to mysql database

#1

I’m new to Metabase. Trying to connect to a MySql 6.5 database on my network. I installed Metabase locally on my MacBook and also launched a Metabase Docker container and can’t connect either to the MySql database. From each instance I get

Couldn’t connect to the database. Please check the connection details

I can connect to the database with MySqlWorkbench using the same connection info.

Is this a common problem with a common solution? Or, is there more detailed logging available in Metabase?

Thanks

#2

Hi & welcome!

The more detailed logs are available in the UI in the top right menu.

Sounds like you are already halfway there with troubleshooting. :+1: The :blue_book: Troubleshooting Guide has a few more steps for you to try in the Connecting to databases and data warehouses with Metabase section.

#3

Thanks jornh. The logs were helpful. On both my local install and my network Docker install I’m getting a similar error:
Failed to connect to database: java.sql.SQLException: Access denied for user '_username_'@'x.x.x.x' (using password: YES)

where x.x.x.x is the IP address of the machine running Metabase, not the IP address of the database server I entered on the config screen.

So when attempting to make the connection, Metabase appears to be using the proper database username but is replacing the DB server IP address I specified with the local machine IP.

There was nothing in the troubleshooting guide about this. Any suggestions are appreciated.

#4

One other thing…the Docker container appears to have network connectivity, I was able to drop into the container and ping out to the database server:

[root@todd ~]# docker exec -it de3 ping x.x.x.x
PING x.x.x.x (x.x.x.x): 56 data bytes
64 bytes from x.x.x.x: seq=0 ttl=63 time=0.424 ms
#5

Are you by any chance running this with SSL/SSH tunnel? Think there was an issue open on GitHub related to this… edit this: https://github.com/metabase/metabase/pull/6970 (exec with an unmerged PR)

Also, it could help understanding your environment better if you shared (somewhat redacted/obfuscated) settings.

#6

Dear @toddlamothe do you fixed the problem ?

I have a Metabase installed in one container and have other container with database MySQL.

When try to connect Metabase in Database MySQL occur error as image.

image

Can you help me ?

Tks,

Diego

#7

@kmargo
You need to figure out what IP address the MySQL container has and connect to that - might need to make a bridge in Docker and/or make sure a firewall isn’t blocking the connection:
https://docs.docker.com/compose/networking/
https://stackoverflow.com/questions/51360236/how-to-get-a-docker-containers-ip-address-located-within-a-bridge-network-fro/51362403
localhost is the system name, usually referencing the internal IP 127.0.0.1, so if you input that in the Metabase container, then it will try to make the connection inside that container.

#8

Hi @flamber tks for your help.

The container accept the connection now.

I have other error now in metabase.

I’m certain about the password is correct.

Do you know some thing about this issue ?

Tks,

Diego

#9

@kmargo

I’m not sure if you’re referring to the first error or the second.

The first error looks like an issue with hostname mysql does not exist. And then something about certificate issue.

The second error says that it’s not using a password for the login - this could be because you’re not including a certificate correctly (if your MySQL is using that) or maybe because you’re using MySQL 8, which you need to change to the native auth.

#10

Hi @flamber continue here and with problem. :confused:

I get to connect in Metabase, in other contanier with MySQL. But now I have this issue in metabase when I try to connect in Database.

Error:
java.sql.SQLException: The connection property ‘zeroDateTimeBehavior’ acceptable values are: ‘CONVERT_TO_NULL’, ‘EXCEPTION’ or ‘ROUND’. The value ‘convertToNull’ is not acceptable.

Do you have ideia what this problem ?

Tks again.

Diego

#11

@kmargo
It sounds like you’re using a connection parameter zeroDateTimeBehavior, but only the three options listed are valid. So it should be:
zeroDateTimeBehavior=CONVERT_TO_NULL

#12

@flamber I don´t understood !

Do you know what have to do to fix this ?

Tks,

Diego

#13

@kmargo
Which version of Metabase? Which version of MySQL?
Are you using connection parameters when inputting the database details? If yes, then post those. If no, then try inputting the following:
zeroDateTimeBehavior=CONVERT_TO_NULL

#14

HI @flamber, this versions.

Metabase
https://hub.docker.com/r/sharifmalik007/metabase

MySQL
https://hub.docker.com/_/mysql

#15

@kmargo
Well, there’s your problem. You’re not using Metabase’s version:
https://hub.docker.com/r/metabase/metabase
And just listing a Hub link, doesn’t tell me which version of MySQL you’re using.

#16

Hi @flamber, tks your replay.

Metabase
image

MySQL 8.0.15

Tks,

Diego

#17

@kmargo
It doesn’t matter. Use the official Metabase docker.
Metabase works with MySQL 8, but you need to use native auth.