join Grafana to a distant MySQL database

Grafana wants information to be helpful. Jack Wallen walks you thru the method of utilizing a MySQL database as a supply for information visualization in Grafana.

Picture: Grafana

Grafana is among the most widely-used interactive information visualization instruments available on the market. It’s open-source, highly effective, extremely configurable and free to make use of. I’ve walked you thru the method of putting in Grafana on Ubuntu Server 20.04, and this time round I’ll enable you to join that newly put in platform to a MySQL database, so you may visualize that information.

Grafana permits you to hook up with quite a few information sources (Google Sheets, Amazon Timestream, Elasticsearch and plenty of databases). As a result of MySQL is such a preferred database, I assumed that may be an incredible information supply to make use of as an illustration. This may even refresh your reminiscence on how one can set MySQL up for distant connections.

SEE: 40+ open supply and Linux phrases it is advisable know (TechRepublic Premium)

What you’ll want

To make this work, you’re going to want a operating occasion of Grafana, a operating occasion of MySQL and a person with sudo privileges. I’m going to imagine your occasion of MySQL is on a distant Linux server.

configure MySQL for distant connection

The very first thing we should do is configure the MySQL server to permit distant connections. On high of that, we’re going to create a particular person that has particular permissions for the database we’ll view on Grafana.

First, log into your MySQL server and open the MySQL configuration file with:

sudo nano /and so forth/mysql/mysql.conf.d/mysqld.cnf

In that file, search for the road:

bind-address =

Change that to:

bind-address =

Save and shut the file. Restart the MySQL service with:

sudo systemctl restart mysql

Subsequent, we have to create a brand new person and provides it the proper permissions. Log in to the MySQL console with:

sudo mysql -u root -p

Ensure you know which database you’re going to be utilizing. You possibly can checklist them out with:

present databases;

Create the brand new person with:


The place PWORD is a robust/distinctive password for the brand new person.

Now, we are able to grant that new person the SELECT permission for the database with:

GRANT SELECT ON DB.* TO 'grafanareader';

The place DB is the identify of the database to be learn by Grafana.

Flush the privileges and exit from the MySQL console with:

flush privileges;

Your database server is now prepared.

join Grafana to MySQL

Log into your Grafana occasion and click on the gear icon within the left sidebar. From the ensuing popup, click on Information Sources. Within the subsequent window, scroll down and choose MySQL from the itemizing. You’ll then be introduced with the required configuration choices for a MySQL information connection (Determine A).

Determine A

The MySQL Grafana configuration editor.

Right here’s what you need to fill out:

  • Host—the IP handle or area identify of the MySQL internet hosting server together with the port used for the database server (default is 3306).
  • Database—the database for use as a supply.
  • Consumer — grafanareader
  • Password—PWORD used to create grafanareader within the MySQL console.

You may additionally must allow Skip TLS Confirm.

Configure these choices and click on Save & Take a look at. You need to finally see Database Connection OK (Determine B).

Determine B

Our MySQL connection is sweet to go.

Congratulations, you now have Grafana related to a distant MySQL server. In our subsequent piece within the collection, we’ll create a brand new dashboard to view a number of the information from the supply.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise execs from Jack Wallen.

Leave a Comment