# How to add mysql datasource to grafana

**URL:** <https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197>\
**Category:** MySQL\
**Tags:** mysql\
**Created:** [September 5, 2018, 6:25am UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197 "2018-09-05T06:25:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![draxayani](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@draxayani](https://community.grafana.com/u/draxayani)\
**Post date:** [September 5, 2018, 6:25am UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/1 "2018-09-05T06:25:29Z")

</div>

Hi i am using grafana first time please suggest me how to add a mysql data source into grafana

---

<div class="post-metadata">

**Author:** ![avi2e4e3](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@avi2e4e3](https://community.grafana.com/u/avi2e4e3)\
**Post date:** [September 10, 2018, 9:49am UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/2 "2018-09-10T09:49:54Z")

</div>

Go to Datasources, give the url link of where your sql db is stored

ex:- yourserver:port number

ex:-localhost:8000(change it to whichever port youre running sql on)

---

<div class="post-metadata">

**Author:** ![geetu](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@geetu](https://community.grafana.com/u/geetu)\
**Post date:** [September 10, 2018, 12:33pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/3 "2018-09-10T12:33:33Z")

</div>

hi,

i have a little bit of idea about it hope it can help you

Go to Datasources -\>select type as mysql-\>the give url on which your mysql is working (it generally works on 3306 port)-\>then enter database name -\> and enter username and password of your mysql then the connection will be created.

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [September 21, 2018, 12:48pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/4 "2018-09-21T12:48:10Z")

</div>

Please refer to the [documentation](http://docs.grafana.org/features/datasources/mysql/#adding-the-data-source)

---

<div class="post-metadata">

**Author:** ![danilofm](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@danilofm](https://community.grafana.com/u/danilofm)\
**Post date:** [September 21, 2018, 4:49pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/5 "2018-09-21T16:49:54Z")

</div>

Hi, I have the same doubt about it. I have followed all the steps described in documentation and the step described by geetu and I am getting an error in my grafana:

Templating init failed

Error 1146: Table ‘my2.status’ doesn’t exist

I google it but couldn’t find any awnser about this error. Can anyone help?  
Thanks

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [September 21, 2018, 8:57pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/6 "2018-09-21T20:57:22Z")

</div>

That error tells you that you have a template variable defined in a dashboard that tries to read from my2.status table which you doesn’t seem to have in your database.

---

<div class="post-metadata">

**Author:** ![billabongrob](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@billabongrob](https://community.grafana.com/u/billabongrob)\
**Post date:** [December 21, 2018, 7:22pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/7 "2018-12-21T19:22:47Z")

</div>

Hello @danilofm  
It looks like you’ve installed the dashboard but not the necessary database for use with that dashboard. I ran into the same. See the authors git repo here. It will import a my2 table with some stored functions.

> **[GitHub - meob/my2Collector: My2Collector (my2) is a simple, self contained...](https://github.com/meob/my2Collector)**
>
> My2Collector (my2) is a simple, self contained MySQL statistics collector - GitHub - meob/my2Collector: My2Collector (my2) is a simple, self contained MySQL statistics collector

---

<div class="post-metadata">

**Author:** ![robertconnelly](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@robertconnelly](https://community.grafana.com/u/robertconnelly)\
**Post date:** [April 15, 2021, 8:45pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/8 "2021-04-15T20:45:20Z")

</div>

I had my2 installed and using mysql and it was working.  
Now the native plugin for mysql is missing and giving the same error as above.  
Not sure where mysql plugin went. Cannot even add a new dashboard with mysql as its no longer an option. Trying to find the plugin to re-install now.

---

<div class="post-metadata">

**Author:** ![robertconnelly](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@robertconnelly](https://community.grafana.com/u/robertconnelly)\
**Post date:** [April 16, 2021, 3:54pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/9 "2021-04-16T15:54:45Z")

</div>

Here is the log

t=2021-04-15T14:58:37+0000 lvl=eror msg=“query error” logger=tsdb.mysql err=“Error 1049: Unknown database ‘exampledb’”  
t=2021-04-15T16:03:05+0000 lvl=info msg=“Request Completed” logger=context userId=1 orgId=1 uname=admin method=POST path=/api/dashboards/db status=412 remote\_addr=192.168.220.54 time\_ms=20 size=88 referer=“[http://192.168.220.145:3000/d/\*\*\*\*\*\*\*/2mysql-simple-dashboard?orgId=1&from=1618400760373&to=1618433110141](http://192.168.220.145:3000/d/ ******* /2mysql-simple-dashboard?orgId=1&from=1618400760373&to=1618433110141)”  
t=2021-04-15T17:56:20+0000 lvl=eror msg=“Could not find plugin definition for data source: mysql”  
t=2021-04-15T17:56:20+0000 lvl=eror msg=“Could not find plugin definition for data source: mysql”  
t=2021-04-15T17:56:33+0000 lvl=eror msg=“Could not find plugin definition for data source: mysql”  
t=2021-04-15T17:56:33+0000 lvl=eror msg=“Could not find plugin definition for data source: mysql”  
t=2021-04-15T17:56:33+0000 lvl=eror msg=“Could not find plugin definition for data source: mysql”

---

<div class="post-metadata">

**Author:** ![robertconnelly](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@robertconnelly](https://community.grafana.com/u/robertconnelly)\
**Post date:** [April 16, 2021, 4:12pm UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/10 "2021-04-16T16:12:21Z")

</div>

Did a dpkg install over the existing and mysql is now an option again.  
Did not lose any of my existing dashboards 🙂

---

<div class="post-metadata">

**Author:** ![prasadbanu79](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@prasadbanu79](https://community.grafana.com/u/prasadbanu79)\
**Post date:** [March 4, 2024, 9:42am UTC](https://community.grafana.com/t/how-to-add-mysql-datasource-to-grafana/10197/11 "2024-03-04T09:42:56Z")

</div>

Hi i have added mysql datasource and its connection is ok but when i installed mysql dashboard in that dashboard it is not showing mysql datasource and it is only showing the prometheus datasource why?
