Cloud Native 4 min read

How to Install and Configure mysql_exporter on a Kubernetes Master Node

This guide walks through downloading the mysql_exporter package, extracting it on a Kubernetes master, installing the binary, creating a dedicated MySQL user with proper permissions, configuring a password‑less client file, launching the exporter, and updating Prometheus via kubectl so MySQL metrics are exposed on port 9104.

Full-Stack DevOps & Kubernetes
Full-Stack DevOps & Kubernetes
Full-Stack DevOps & Kubernetes
How to Install and Configure mysql_exporter on a Kubernetes Master Node

This article provides a step‑by‑step procedure for setting up mysqld_exporter on a Kubernetes master node to expose MySQL performance metrics to Prometheus.

Download and extract the exporter

tar -xvf mysqld_exporter-0.10.0.linux-amd64.tar.gz

Install the binary

cd mysqld_exporter-0.10.0.linux-amd64
cp -ar mysqld_exporter /usr/local/bin/

Make the binary executable

chmod +x /usr/local/bin/mysqld_exporter

Create a MySQL user for the exporter

mysql> CREATE USER 'mysql_exporter'@'localhost' IDENTIFIED BY 'Abcdef123!.';
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysql_exporter'@'localhost';
mysql> exit

Configure a password‑less client file

[client]
user=mysql_exporter
password=Abcdef123!.

Run the exporter

nohup ./mysqld_exporter --config.my-cnf=./my.cnf &

The exporter listens on port 9104.

Add a Prometheus job for MySQL

scrape_configs:
  - job_name: 'mysql'
    static_configs:
      - targets: ['192.168.124.16:9104']

Apply the updated Prometheus configuration

kubectl delete -f prometheus-cfg.yaml
kubectl apply -f prometheus-cfg.yaml
kubectl delete -f prometheus-deploy.yaml
kubectl apply -f prometheus-deploy.yaml

After reloading, Prometheus begins collecting MySQL metrics from the exporter.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringCloud NativeKubernetesDevOpsmysql_exporter
Full-Stack DevOps & Kubernetes
Written by

Full-Stack DevOps & Kubernetes

Focused on sharing DevOps, Kubernetes, Linux, Docker, Istio, microservices, Spring Cloud, Python, Go, databases, Nginx, Tomcat, cloud computing, and related technologies.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.