Problems with docker mysql and connector in Grafana

  • What Grafana version and what operating system are you using?

I have run a docker container with this configuration:

  grafana:
    image: grafana/grafana-oss:11.1.3-ubuntu
    container_name: grafana
    tty: true
    stdin_open: true
    volumes:
      - ../grafana/config:/etc/grafana-config
      - ../grafana/datasources:/etc/grafana/provisioning/datasources
      - ../grafana/dashboards-provisioning:/etc/grafana/provisioning/dashboards
      - ../grafana/dashboards:/var/lib/grafana/dashboards
    ports:
      - "3000:3000"
  • What are you trying to achieve?

Create a connection to a MySQL container:

  mysql:
    # profiles: [ integrations, mysql ]
    image: mysql/mysql-server:5.7
    container_name: mysql-server
    tty: true
    stdin_open: true
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_ROOT_HOST=%
      - MYSQL_DATABASE=db1
    ports:
      - "3306:3306"
    expose:
      - "3306"
    volumes:
      - ../mysql:/var/lib/mysql
  • How are you trying to achieve it?

I’m trying to use Data Sources inside Grafana (I already did it using DBeaver).

  • What happened?

I’m getting: failed to connect to server - please inspect Grafana server log for details

  • What did you expect to happen?

Create a connection to get the data inside a database.

  • Can you copy/paste the configuration(s) that you are having problems with?

URL: http://172.20.0.5:3306 (the container IP)
the rest is as usual, everything is as expected.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

I dive into the Grafana container and there was no log file.

  • Did you follow any online instructions? If so, what is the URL?

How do you know that’s correct container IP?

I would use container name (mysql-server), not IP which can be changed after next container restart.

are these 2 separate containers?

I know the IP running docker inspect + container name. It doesn’t change.

They are separated container in the same docker-compose, so that means they are sharing the same network.