How to connect MySQL DataBase with grafana

Hello,

I try to connect grafana with mySQL DB, in Data Sources.
image
I have this message error:
dial tcp [::1]:3306: connect: connection refused
Thank you for your helping,

Theofane Bidaud

Is your mysql listening on port 3306? Possible that your firewall (iptables, firewalld etc) is blocking the connection?

What happens if you: telnet localhost 3306

?

Hi,

Yes, it’s my port 3306 that he blocked the connection. I unlock the port 3306 on my PC and it’s done.

Thank you for your helping

Theofane Bidaud

Mob: 02.40.45.97.74

GEPS Techno

27, Boulevard des Apprentis 44600 Saint-Nazaire

I was able to connect via telnet as well run mysql query using “-e” option, but still not able to connect via grafana.net. I used to connect before not sure what has changed now.
I dont have firewall setup in my mac,
I have access permission, consiering tcp connect fails, I dont think this is a permission issue
Chrome response information

{results: {,…}, message: “dial tcp [::1]:3306: connect: connection refused”}
message: “dial tcp [::1]:3306: connect: connection refused”
results: {,…}
A: {error: “dial tcp [::1]:3306: connect: connection refused”, refId: “A”, meta: {sql: “SELECT 1”},…}

where are mysql server?

even i am facing some error while adding data source in Grafana
The error is like this authentication plugin is not supported
can anyone help with this

Can you access the database using the mysql command line utility with the user and pwd?
If yes then show us how you have configured it and the exact error message.

I am connecting to my mysql server in my mac using
https://gtpraveenkumar.grafana.net/datasources/edit/5/
All configurations are default, except for database name and user credentials. Database name and user credentials are working with mysql cli, by the way this is not an authentication issue, this is a connection issue.

Following is the Error
dial tcp [::1]:3306: connect: connection refused

So the question is why graphana that is running in my chrome in my mac is not able to connect to the mysql server which is running in the same mac

Possibly a difference between the ip address grafana is trying to connect with and the setting for bind_address in your mysql conf. If you have not changed the setting in mysql then it will probably be 127.0.0.1. Try using that for the host for the data source. If that doesn’t work then have a look in the mysql conf file and see what it is. If it is an ip address then use that in the data source.

/usr/local/mysql/bin/mysql -h 127.0.0.1 --port=3306 -u root -p

above command works, but grafana connection fails, i tried localhost:3306 as host as well

port is in listening mode

BT-C02RJ4XDG8WN:~ praveen.gt$ netstat -an | grep 3306
tcp46 0 0 *.3306 . LISTEN

What exact error are you seeing when you use 127.0.0.1?

As mentioned before

Following is the Error if I use localhost as hostname
dial tcp [::1]:3306: connect: connection refused

Following is the Error if I use 127.0.0.1 as hostname
dial tcp 127.0.0.1:3306: connect: connection refused

Very odd. I presume all this (mysql and grafana) are running on the same machine.
Try putting the IP address of the machine in bind_address in the mysql config, restart mysql, then check you can connect using the command line and that ip for the host and then try in grafana. That may not be acceptable as a final solution but will prove it is something to do with that. If you are running a firewall on the machine you may have to temporarily open that port, only on that machine though, not open it in the router. If the command line access using the IP works then there is not a firewall issue.

Hi, the problem that you have is called NAT, which means that grafana.net can not reach your MAC, since they are in different networks. To solve your problem you have the following three options:

  • Make your MAC accessible from grafana.net
    For this you must know your public ip, configure your router to open port 3306 to your MAC in addition to the firewall configuration on your MAC (which I do not know) and after all this, you must configure your datasource in grafana.net so that it points to your ip publishes.
  • Use an external mysql service, which is accessible from any point on the internet (Amazon, Azure, Google)
  • Install grafana on your MAC
    This is the easiest Download

Oh, I had not realised the significance of the link in post 7, @gtpraveenkumar is not running grafana on the local machine, I should have realised.

I unlocked port 3306 the following way: https://www.youtube.com/watch?v=ayj6B3ZYw38
However, i still keep this error dial tcp 127.0.0.1:3306: connect: connection refused, what can i do about it?

Are you able to connect to the database using another sql client such as the mysql command line client?

Yes. By running everything locally it now works

Hi guys i have the same problem…

i have a Grafana installed local y my windows 7 computer, i have running mysql server , i can connect with WorkBench to my Mysql server insert data , all working fine…

But when i try to add a Mysql Datasource an error is showed…

Query failed. Please inspect Grafana server log for details

the logs show

t=2020-09-11T20:49:30-0400 lvl=eror msg=“query error” logger=tsdb.mysql err=“Error 1045: Access denied for user ‘admin’@‘localhost’ (using password: YES)”

t=2020-09-11T20:49:30-0400 lvl=info msg=“Request Completed” logger=context userId=1 orgId=1 uname=admin method=POST path=/api/tsdb/query status=400 remote_addr=[::1] time_ms=53 size=261 referer=http://localhost:3000/datasources/edit/2/

i do not what iam doing wrong, can you help me to fix ?

Thanks