Connection refused when connecting with Metabase to a MySQL database

I try to connect to a local MySQL database called time_series with metabase but when I connect I get the following error.

Database name: Could not connect to address=(host= : Socket fail to connect to host:, port:3306. Connection refused (Connection refused)

The user doesn't have password

However that is a known problem until it appears that the MariaDB connector, used by Metabase, is currently not compatible with MySQL 8.

So I tried the command they propose:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '';

But it sends back:

Error Code: 1396. Operation ALTER USER failed for 'root'@'%'

How are you connecting Metabase to MySQL? can you provide more info about that? Metabase is perfectly compatible with MySQL 8. E.g. try this docker-compose

version: '3.9'
    image: metabase/metabase-enterprise:v1.43.4
    container_name: metabase-mysql
    hostname: metabase-mysql
    - /dev/urandom:/dev/random:ro
      - 3000:3000
      MB_DB_DBNAME: "metabase"
      MB_DB_PORT: "3306"
      MB_DB_USER: "metabase"
      MB_DB_PASS: "mysecretpassword"
      MB_DB_HOST: "mysql"
      MB_DB_TYPE: "mysql"
      - metanet1-mysql
    image: mysql:8.0.29
    container_name: mysql
    hostname: mysql
      - 3306:3306
      - "MYSQL_ROOT_PASSWORD=mysecretpassword"
      - "MYSQL_USER=metabase"
      - "MYSQL_PASSWORD=mysecretpassword"
      - "MYSQL_DATABASE=metabase"
      - $PWD/mysql-data:/var/lib/mysql
    command: ['--default-authentication-plugin=mysql_native_password', '--mysqlx=0']
      - metanet1-mysql
    driver: bridge

Sure @Luiggi Here is my very simple configuration to connect Metabase to MySQL:

I just tried with your docker-compose.yml file (which I had to change the port from 3306:3306 to 3366:3306) but I still have the same error: Connection refused. is the localhost. If the Metabase App and the database are not running in the same host that won't work. Also, MySQL needs to listen to connections if that hasn't already been configured.

The docker-compose I sent is to connect Metabase with MySQL as the application database, not as a normal data warehouse connection. Also, consider than in my docker-compose file the containers create their own network, so you'll need to make the connections on their own network, so if you need to add the app db as a new data connection in Docker then the host is "mysql" (this is the hostname inside the docker network), the port is "3306" and the user is "metabase" and password "mysecretpassword".

Running Metabase as a JAR file and running in Docker has different considerations, you need to know how the networking works on each

Okay, I figured it out and managed to connect to the default metabase by putting "metabase" in the database to reach. Thank you @Luiggi !

I am now looking to upload my csv data that I already had in my MySQL database accessible by MySQL WorkBench outside of the network data created by docker-compose.yml. I guess I need to connect to the MySQL database created by docker compose and upload my csv file to it. Do you know how I can do this?

Why can't you connect from Metabase to the server you have the data on? you don't need to move the data

I tried, but I still have the same error:

when you type inside a docker container, you're referring to the docker container itself, you don't have a database running inside that docker container, you have Metabase.

If the database is running on the HOST which is hosting the docker container, then you need to change the networking mode from bridge to host

It would be easier if instead of running a container, you run the JAR