MySQL’s built-in metrics are powerful but not easily scraped. Prometheus mysqld_exporter is the standard exporter that translates MySQL status variables, InnoDB engine metrics, and replication lag statistics into the Prometheus exposition format. Combined with Grafana, the mysqld_exporter provides real-time dashboards covering query throughput, connection pool usage, InnoDB buffer pool hit rates, disk I/O, and replication status. This guide covers installing and configuring mysqld_exporter on RHEL 9, scraping it with Prometheus, and importing the official MySQL Overview dashboard into Grafana.

Prerequisites

  • MySQL 8 running on RHEL 9
  • Prometheus and Grafana already installed (or install per the Prometheus/Grafana tutorials)

Step 1 — Create the Monitoring MySQL User

mysql -u root -p <<'SQL'
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'ExporterPass123!' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
SQL

Step 2 — Install mysqld_exporter

EXPORTER_VER="0.15.1"
cd /tmp
curl -LO "https://github.com/prometheus/mysqld_exporter/releases/download/v${EXPORTER_VER}/mysqld_exporter-${EXPORTER_VER}.linux-amd64.tar.gz"
tar xzf mysqld_exporter-${EXPORTER_VER}.linux-amd64.tar.gz
install -m 0755 mysqld_exporter-${EXPORTER_VER}.linux-amd64/mysqld_exporter /usr/local/bin/

Step 3 — Configure the Exporter Credentials

# /etc/mysqld_exporter.cnf (mode 600, owned by mysql system user)
[client]
user=exporter
password=ExporterPass123!
host=127.0.0.1
port=3306
useradd -rs /bin/false mysqld_exporter
chown mysqld_exporter:mysqld_exporter /etc/mysqld_exporter.cnf
chmod 600 /etc/mysqld_exporter.cnf

Step 4 — Create the systemd Service

# /etc/systemd/system/mysqld_exporter.service
[Unit]
Description=Prometheus MySQL Exporter
After=network.target mysql.service

[Service]
User=mysqld_exporter
Group=mysqld_exporter
ExecStart=/usr/local/bin/mysqld_exporter 
    --config.my-cnf=/etc/mysqld_exporter.cnf 
    --collect.info_schema.tables 
    --collect.info_schema.innodb_metrics 
    --collect.global_status 
    --collect.global_variables 
    --collect.slave_status
Restart=always

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now mysqld_exporter
curl -s http://localhost:9104/metrics | head -20

Step 5 — Configure Prometheus to Scrape mysqld_exporter

# Add to /etc/prometheus/prometheus.yml under scrape_configs:
  - job_name: 'mysql'
    static_configs:
      - targets: ['localhost:9104']
systemctl reload prometheus

Step 6 — Import Grafana MySQL Dashboard

# In Grafana UI:
# 1. Click Dashboards → Import
# 2. Enter dashboard ID: 7362  (MySQL Overview by Percona)
# 3. Select your Prometheus data source
# 4. Click Import

# Key panels:
# - MySQL Questions (queries/sec)
# - InnoDB Buffer Pool Hit Rate (target: >99%)
# - Active Connections vs Max Connections
# - InnoDB Row Operations (reads/writes/deletes per sec)
# - Replication Lag (seconds_behind_source)

Conclusion

The Prometheus mysqld_exporter on RHEL 9 provides deep visibility into MySQL internals without requiring any MySQL plugin installation. The InnoDB buffer pool hit rate is the most actionable metric — if it drops below 99%, the innodb_buffer_pool_size in /etc/my.cnf should be increased (typically 70–80% of available RAM). Monitor active connections against max_connections to detect connection pool exhaustion before it becomes an outage.

Next steps: How to Install Prometheus and Node Exporter on RHEL 9, How to Install Grafana on RHEL 9, and How to Configure MySQL Primary-Replica Replication on RHEL 9.