Can't connect grafana to MYSQL database

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

Ubuntu 22.04, grafana 10.4

  • What are you trying to achieve?

I’m trying to get grafana OSS to use MYSQL instead of SQLITE. I’ve read the documentation and tried several different options, using the URL, putting the password in quotes etc. and nothing seems to make any difference. I’ve searched google and found lots of people with this problem on this forum etc. but no working solutions.

  • How are you trying to achieve it?

Updating the grafana.ini file

  • What happened?

It doesn’t appear to connect

  • What did you expect to happen?

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

type = mysql
host = x.x.x.x:3306
name = grafana
user = grafana
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
password = *********

# Use either URL or the previous fields to configure the database
# Example: mysql://user:secret@host:port/database

# For "postgres" only, either "disable", "require" or "verify-full"
;ssl_mode = disable
ssl_mode = disable
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

logger=settings t=2024-05-08T17:19:50.312049257Z level=info msg=“Config overridden from command line” arg=“default.paths.provisioning=/etc/grafana/provisioning”
logger=settings t=2024-05-08T17:19:50.312169251Z level=info msg=Target target=[all]
logger=settings t=2024-05-08T17:19:50.312293788Z level=info msg=“Path Home” path=/usr/share/grafana
logger=settings t=2024-05-08T17:19:50.312394085Z level=info msg=“Path Data” path=/var/lib/grafana
logger=settings t=2024-05-08T17:19:50.312485858Z level=info msg=“Path Logs” path=/var/log/grafana
logger=settings t=2024-05-08T17:19:50.312742828Z level=info msg=“Path Plugins” path=/var/lib/grafana/plugins
logger=settings t=2024-05-08T17:19:50.313093094Z level=info msg=“Path Provisioning” path=/etc/grafana/provisioning
logger=settings t=2024-05-08T17:19:50.313270993Z level=info msg=“App mode production”
logger=sqlstore t=2024-05-08T17:19:50.318668458Z level=info msg=“Connecting to DB” dbtype=mysql
logger=migrator t=2024-05-08T17:19:50.322553067Z level=info msg=“Starting DB migrations”

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

welcome @mriddle1

How have you configured mysql as far as remote connections allowed from remote hosts?

Yes, I can connect to it via the command line on the grafana server, so I know there is no problem with networking or the credentials.

answered in slack. your issue is not in grafana. it is a configuration and permission issue.

@mriddle1 solved this by

  1. giving the proper permissions in the RDS database to the user configured in the ini file
  2. using SSL setting in grafana
    ssl_mode = true