How to Monitor MySQL/MariaDB through Prometheus & Grafana ?

Опубликовано: 12 Май 2026
на канале: Avinashkumar - The Learning Destination
11,052
116

Please follow the below steps to install mysqld_exporter.

curl -s https://api.github.com/repos/promethe... | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
tar xvf mysqld_exporter*.tar.gz
sudo mv mysqld_exporter-*.linux-amd64/mysqld_exporter /usr/local/bin/
sudo chmod +x /usr/local/bin/mysqld_exporter

CREATE USER mysqld_exporter IDENTIFIED BY 'PASSWD';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON . TO 'mysqld_exporter';
FLUSH PRIVILEGES;
EXIT

Configure DB Credential
sudo vi /etc/.mysqld_exporter.cnf

[client]
user=mysqld_exporter
password=PASSWD
host=192.168.56.109

Change ownership
sudo chown root:prometheus /etc/.mysqld_exporter.cnf

Create Systemd File
sudo vi /etc/systemd/system/mysql_exporter.service

[Unit]
Description=Prometheus MySQL Exporter
After=network.target
User=prometheus
Group=prometheus

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/mysqld_exporter \
--config.my-cnf /etc/.mysqld_exporter.cnf \
--collect.global_status \
--collect.info_schema.innodb_metrics \
--collect.auto_increment.columns \
--collect.info_schema.processlist \
--collect.binlog_size \
--collect.info_schema.tablestats \
--collect.global_variables \
--collect.info_schema.query_response_time \
--collect.info_schema.userstats \
--collect.info_schema.tables \
--collect.perf_schema.tablelocks \
--collect.perf_schema.file_events \
--collect.perf_schema.eventswaits \
--collect.perf_schema.indexiowaits \
--collect.perf_schema.tableiowaits \
--collect.slave_status \
--web.listen-address=0.0.0.0:9104

[Install]
WantedBy=multi-user.target


sudo systemctl daemon-reload
sudo systemctl enable mysql_exporter
sudo systemctl start mysql_exporter

Import Mysql Grafana Dashboard
https://grafana.com/grafana/dashboard...