Skip to content


 Zabbix
 Grafana
 Prometheus
 Threejs and TypeScript
 SocketIO and TypeScript
 Blender Topological Earth
 Sweet Home 3D
 Design Patterns Python
 Design Patterns TypeScript
   
 Course Coupon Codes
Python   TypeScript
Kindle Edition Kindle Edition
$9.99 $14.99 $9.99 $14.99
Paperback Paperback
$14.99 $19.99 $14.99 $19.99








Install MySQL Dashboard and Collector

Video Lecture

Install MySQL Dashboard and Collector Install MySQL Dashboard and Collector Install MySQL Dashboard and Collector

Description

Now we have a MySQL Data Source created, we will install a dashboard for it.

The dashboard will be the popular 2MySQL Simple Dashboard you can download from https://grafana.com/grafana/dashboards?dataSource=mysql

Before installing the dashboard, we need to set up a collector on our MySQL server. The collector script is downloaded from https://github.com/meob/my2Collector

I have MySQL 8.0.21, so I will download the file called my2_80.sql If you have MySQL 5, then download my2.sql

I download the script using wget,

1
wget https://raw.githubusercontent.com/meob/my2Collector/master/my2_80.sql

The event scheduler will also need to be enabled on your MySQL server. You can do this by editing the my.cnf file

1
sudo nano /etc/mysql/my.cnf

Add lines

1
2
3
...
[mysqld]
event_scheduler = on

Save, and restart,

1
sudo service mysql restart

Open the script that was downloaded

1
sudo nano my2_80.sql

Uncomment the last 2 lines. Set the password to something you want, and save

Run the sql script,

1
mysql < my2_80.sql

Open MySQL and so some checks.

1
mysql
1
2
3
4
5
6
7
> show databases;
> show variables where variable_name = 'event_scheduler';
> use my2;
> show tables;
> select * from current;
> select * from status;
> quit

If everything is ok, continue

Import the new dashboard using the Grafana GUI as shown in the video lecture, I have an error after installing the Dashboard, that the SELECT command is denied for user grafana@localhost I need to grant SELECT to the user on the new database my2 which was created when running the my2_80.sql script.

1
mysql
1
2
3
> GRANT SELECT ON my2.* TO 'grafana'@'localhost';
> FLUSH PRIVILEGES;
> quit

Reopen the dashboard, and you should begin to see data.

Note that there are now 2 database users,

  1. grafana@localhost : Used by the Grafana dashboard, to query the collected data from the MySQL server. This user has been granted the SELECT privilege only.

  2. my2@localhost: Used by the MySQL event scheduler to collect statistics and save them into the DB for use by the Grafana dashboard. This user has been granted ALL privileges.