Grafana and Mariadb

I’m trying to connect my mariadb to grafana as a data source
but every time I try to connect it grafana show me an error message
dial tcp ip:3306: connect: connection refused

I run a moodle server on ubuntu 18.04 over AWS, the security group was configured to allow access through the 3306 port so not sure where I went wrong.

Starting from the machien running Grafana, what result do you get from:

telnet IP 3306

where IP is the address of your MariaDB server (and the same address as you’re
entering into Grafana)?

If that works, you should get a response from the MariaDB server something

Connected to
Escape character is ‘^]’.

If it does not work, then you have a network connectivity problem between the
Grafana server and the MariaDB server.

If it does work, go to the MariaDB server and use the command line client to
find out what permissions you have for the user you are telling Grafana to log
in as:

mysql mysql -e “select * from user where User=‘GrafanaUsername’”