Grafana Installation with MySQL Database

In this article, we will install and configure Grafana with the MySQL database. Grafana is an open-source monitoring and data visualization tool. Grafana uses MySQL for storing Users, sessions, and dashboard ( You can use other databases as well).  Let’s start with Grafana installation.

Lab setup

OS:  Amazon Linux.

Grafana version: 6.3.2

Hosted on: AWS

Database: MySQL

Grafana Installation

Download the rpm package from the official Grafana website. The below link helps you to get it.

https://grafana.com/grafana/download?platform=linux

Execute the below command to install the Grafana package.

[root@techiescorner ~]# wget https://dl.grafana.com/oss/release/grafana-6.3.2-1.x86_64.rpm

[root@techiescorner ~]# yum localinstall grafana-6.3.2-1.x86_64.rpm

Once the installation completed we can start the service with the following command.

[root@techiescorner ~]# service grafana-server start

Check server status with the below command.

The default port of Grafana is 3000, make sure that you have opened it in the firewall.

Database Configuration

Login to the MySQL and execute the below commands to create a user and password and grant access for the user over the database.

mysql> create database grafana;

Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on grafana.* to grafana@localhost identified by "Techies123";

Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql> exit

Add database details in the Grafana configuration file. The location will be

/etc/grafana/grafana.ini  Please refer below screenshot.

Restart the Grafana service to pick up the newly added database details.

[root@techiescorner ~]# service grafana-server restart

Stopping Grafana Server: ...                               [  OK  ]

Starting Grafana Server: ...                               [  OK  ]

Now try to access the Grafana interface from the browser, HTTP://< your server IP>:3000. The default Username and Password is “admin”.

Once you logged in the first time you need to change the password.

From the Grafana home page click on the “Add database” option to add database details. Refer below screenshot

 

By clicking the “Save&Test” button you can confirm the details are correct. If you are getting any error, please make sure you have used correct the database name, user and password. Also, make sure that the user has access to the associated database.

 

Leave a Reply

Your email address will not be published. Required fields are marked *