---
title: "Deploy MySQL Metrics Prometheus Exporter"
description: "A Prometheus exporter for gathering metrics about your MySQL DB"
category: "Observability"
url: https://railway.com/deploy/H5G_9i
---

# Deploy MySQL Metrics Prometheus Exporter

A Prometheus exporter for gathering metrics about your MySQL DB

**[Deploy MySQL Metrics Prometheus Exporter on Railway](https://railway.com/template/H5G_9i)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/H5G_9i/manifest.json

- **Creator:** Zuchka Studios
- **Category:** Observability
- **Total deploys:** 19

## Template content

### mysql-metrics-collector

- **Source:** https://github.com/zuchka/railway-mysql-exporter
- **Public domain:** Yes

## Documentation

## MySQL Metrics Collector for Railway

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/H5G_9i?referralCode=9kQOPq)

## How to replace user `root` with user `exporter`

This template will work immediately on any railway project that has a MySQL database deployed. However, it uses the `root` user for access, which is not ideal.

For better security, you should set up a dedicated `exporter` user in your MySQL DB. The following are detailed instructions for setting that up and adjusting the Railway environmental variables:

1) log into your MySQL DB locally using Railway's connection procedures. These are listed in your MySQL details page.

2) run the following commands to create a new user named `exporter`. Be sure to replace `XXXXXXXX` with a strong password of your choosing:

```sql
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
```

3) Return to the Railway UI. Navigate to your MySQL Collector service and add one new environmental variable: create a key called `MYSQL_EXPORT_PASSWORD` and set the value to your new password. The `MYSQL_EXPORT_USER` variable is already set to `exporter`.

4) Update the `Dockerfile` and the `.my.cnf` file in your github repo. The appropriate replacement lines are already present, but commented out. Comment-out the old lines and uncomment these new lines. Push your changes. Railway will redeploy the collector with the new settings. Your collector is now using a dedicated `exporter` user instead of the `root` user!


## Similar templates

- [Rootprint](https://railway.com/deploy/rootprint-1) — Open-source logs and traces with full-text search on object-storage.
- [VPS Fleet Watch Hub with Beszel](https://railway.com/deploy/vps-fleet-watch-hub-with-beszel) — A persistent Beszel hub for external VPS agents and fleet alerts.
- [Pyroscope profiling](https://railway.com/deploy/pyroscope-profiling) — Protected continuous profiling with durable Pyroscope storage.

Open this page in a browser: https://railway.com/deploy/H5G_9i
