Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Database Monitoring

How to Monitor MySQL and MariaDB With Prometheus on a Linux VPS

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run the official Prometheus mysqld_exporter beside your MySQL or MariaDB server, give it a dedicated least-privilege account, let Prometheus scrape its HTTP endpoint, and use Grafana for dashboards and alerts. The exporter supports MySQL 5.6 and newer and MariaDB 10.3 and newer, although individual collectors can have stricter version requirements.

What the monitoring stack does

MySQL and MariaDB do not expose Prometheus-format metrics directly. The exporter logs in to the database, reads status and performance information, converts those values into Prometheus metrics, and serves them over HTTP. Prometheus periodically collects that endpoint and stores the resulting time series. Grafana queries Prometheus to draw dashboards, evaluate recording rules, and send alerts.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical Linux VPS layout is:

  1. Database: MySQL or MariaDB running on the VPS.
  2. Exporter: mysqld_exporter on the same VPS or on a protected monitoring host.
  3. Prometheus: the scraper and time-series database.
  4. Grafana: the visualization and alerting layer.

Keeping the exporter close to the database minimizes network exposure. Prometheus still needs network access to the exporter port, normally TCP 9104; that port should be reachable only from the Prometheus host or an approved monitoring network.

Check compatibility and define the scope

The exporter documentation lists these supported server versions:

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Database Supported version Important qualification
MySQL 5.6 or newer Some collection methods are unavailable on older releases.
MariaDB 10.3 or newer Collector support varies by MariaDB version.

Before installing, record the exact database release, whether Prometheus runs locally or remotely, whether the server uses TCP or a Unix socket, and which questions the monitoring must answer. A small VPS may need only availability, connections, throughput, and InnoDB health. A replication server also needs replication-related collectors, while a host-level view requires a separate Linux node exporter.

Pin a tested exporter release in production rather than always downloading the latest binary. Recheck the exporter release notes and the Grafana integration documentation when upgrading MySQL, MariaDB, Prometheus, or Grafana.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a dedicated database account

Do not give the exporter an application password. Create a separate account whose host part matches the connection method. For a local IPv4 TCP connection, the documented pattern is:

CREATE USER 'exporter'@'127.0.0.1' IDENTIFIED BY 'strong-secret' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'127.0.0.1';

PROCESS permits the status inspection needed by several collectors, REPLICATION CLIENT permits replication-status queries, and SELECT allows reads from the relevant metadata and performance tables. These are read-oriented monitoring privileges, not application write privileges.

Connect the exporter to an address that matches this account, such as 127.0.0.1:3306. If you use a Unix socket, create the account for localhost and configure the socket path instead. MySQL and MariaDB distinguish host values, so an account for localhost does not automatically authenticate a connection coming from 127.0.0.1.

The maximum of three connections in the example protects the database from a burst of exporter sessions. Some older MariaDB releases, including 10.1, do not provide this account-level connection-limit feature; on those systems, use the exporter connection limits and conservative scrape settings instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Store the password in a root-readable configuration file or a secret-management system. Avoid putting it in shell history, a world-readable service file, a public container definition, or a process listing that ordinary users can inspect.

Install mysqld_exporter

Released binary

Download a release that matches your operating system and architecture, place the executable in a protected directory such as /usr/local/bin, and create a dedicated unprivileged service account. Keep the binary and its configuration readable by that account but writable only by administrators. Verify the downloaded release according to the project’s published checksums before putting it into service.

The exporter accepts command-line flags and a configuration file. Important settings include:

  • mysqld.address for the database host, port, or socket.
  • mysqld.username for the monitoring account.
  • config.my-cnf for credentials and client settings stored in a file.
  • exporter.query_timeout to stop an individual database query from running indefinitely.
  • exporter.max_open_connections to cap exporter-side database connections.
  • Lock-wait timeout controls to prevent monitoring queries from waiting behind application transactions.

When both command-line and configuration-file values are supplied, values in the client section of the configuration file override the corresponding command-line values. Keep one authoritative configuration to avoid diagnosing a setting that is silently being overridden.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run it as a service

A production service should start after networking and the database are available, restart after a failure, run without root privileges, and bind its HTTP listener to a private address. A typical service definition points to the pinned exporter binary, references a root-owned credentials file, and sets the database address explicitly. After creating the service, start it and inspect its logs for authentication, socket, or collector errors.

Do not bind port 9104 to every public interface unless a firewall still blocks Internet access. The exporter endpoint contains operational database information and is not an end-user web page.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Container deployment

The documented container pattern creates a network, pulls the prom/mysqld-exporter image, publishes port 9104, and supplies a DATA_SOURCE_NAME value. The command-line template is:

export DATA_SOURCE_NAME='user:password@(hostname:3306)/'
./mysqld_exporter

For a container, pass the same variable to the exporter and publish 9104:9104 only on the private interface or internal network. Replace the template credentials and hostname; never commit a real password to a compose file or image layer. A container can reach a database on the host only when its network route and host address are configured correctly, so test the connection from inside the container rather than assuming localhost means the VPS host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure Prometheus to scrape the exporter

Add a scrape job to Prometheus that resolves the exporter host and port. For an exporter on the same VPS, a minimal configuration is:

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

Use the exporter’s private address when Prometheus runs on another machine. Choose a scrape interval appropriate for the workload; very short intervals multiply database queries and exporter connections without necessarily improving diagnosis. Keep the target label meaningful if one Prometheus instance monitors several database servers.

Reload Prometheus using the method provided by your installation. Open the Prometheus targets page and confirm that the job is UP. An DOWN state means Prometheus could not complete the HTTP scrape; it does not by itself prove that the database credentials are wrong.

Verify the complete path

Test each layer in order so a network error is not mistaken for a database privilege error:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
  1. From the exporter host, connect to MySQL or MariaDB with the monitoring account and the same TCP address or socket configured for the service.
  2. Request the exporter’s HTTP metrics endpoint locally and confirm that it returns Prometheus text rather than an authentication or startup error.
  3. From the Prometheus host, test that the exporter address and TCP 9104 are reachable through the firewall.
  4. In Prometheus, query mysql_version_info and mysql_global_status_connections. Their presence confirms that Prometheus is receiving database metrics.
  5. In Grafana, add Prometheus as the data source and run the same queries in Explore before importing or building dashboards.

If the endpoint responds but the expected metrics are missing, inspect exporter logs and the database account grants. A collector may be disabled, unsupported by the installed server version, or unable to read a required table.

Build useful Grafana dashboards and alerts

Grafana’s MySQL exporter quickstart describes roughly 1,000 default Prometheus time series. That is a configuration-dependent estimate, not a fixed limit: enabling or disabling collectors changes the count, and each additional database target multiplies the stored series.

Start with panels that answer operational questions rather than displaying every metric:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Is monitoring working? Show scrape success, scrape duration, exporter errors, and the age of the last sample.
  • Is the database available? Show server version, uptime, and a clear availability indicator.
  • Are clients exhausting capacity? Show active connections, configured limits where available, and connection saturation over time.
  • Is workload changing? Graph query throughput and latency-related indicators, then compare spikes with deployment or traffic events.
  • Is InnoDB healthy? Track buffer-pool size and activity, plus the storage and lock indicators relevant to your workload.
  • Is replication healthy? Add replication status and lag panels only on servers that actually participate in replication.
  • Is the VPS itself constrained? Add Linux host metrics from a node exporter when CPU, memory, filesystem, or disk pressure can explain database symptoms.

Use alerts with sustained conditions and a clear owner. A brief connection spike may be normal; a persistent saturation condition combined with failed connections is more actionable. Keep exporter reachability alerts separate from database-health alerts so an exporter crash is not confused with a database outage.

The documented Grafana Cloud MySQL integration packages preconfigured dashboards and 15 preconfigured alert rules. Those defaults can accelerate adoption, but review every expression, threshold, notification route, and label before relying on it for production incidents.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Control load and secure the endpoint

Monitoring queries consume resources. Begin with the collectors required by your dashboards, then add others after measuring scrape duration and database impact. On a busy VPS, an exporter that times out or waits on locks can become another source of load.

  • Set a query timeout so a problematic collection does not run forever.
  • Set a lock-wait timeout so monitoring does not remain blocked behind application transactions.
  • Limit exporter-side open connections; the README documents a default maximum of two open connections per scrape.
  • Keep the database account’s host restriction narrow and its privileges limited to the documented monitoring grants.
  • Allow TCP 9104 only from Prometheus or the monitoring network.
  • Use TLS or a private network when the exporter-to-database connection crosses hosts.
  • Watch exporter scrape duration, error counters, and database connection counts after every collector or interval change.

The account limit, exporter connection limit, scrape interval, query timeout, and lock timeout work together. Raising all of them at once can hide the source of load; change one control, observe the result, and retain the smallest values that meet your alerting needs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common failures

Symptom Likely cause What to check
Prometheus target is DOWN Wrong address, blocked port, or exporter not running Exporter service status, local HTTP response, firewall rules, and the Prometheus host’s route to TCP 9104.
Exporter reports access denied Host part does not match or grants are incomplete Connect with the exact configured address and inspect the account definition for 127.0.0.1 versus localhost.
Exporter cannot connect through a socket Socket path is wrong or the account uses a TCP host Find the server’s active socket, configure it explicitly, and create the matching localhost account.
Only some metrics exist Collector disabled, privilege missing, or server version limitation Exporter logs, enabled collectors, grants, and the compatibility notes for the installed MySQL or MariaDB release.
Scrapes time out Slow collection, lock contention, or excessive collectors Scrape duration, database process activity, lock-wait and query-timeout settings, and collector selection.
Database connection count rises unexpectedly Scrape concurrency or insufficient connection limits Prometheus interval and parallelism, exporter maximum open connections, and the account’s MAX_USER_CONNECTIONS.
Grafana panel is empty Wrong data source, label mismatch, or no samples in the selected time range Run a raw PromQL query such as mysql_version_info in Explore and inspect the panel’s job and instance filters.

Self-hosted stack or hosted monitoring?

Self-hosting Prometheus and Grafana gives you direct control over collectors, scrape intervals, retention, network placement, upgrades, and alert routing. It also makes you responsible for patching, backups, storage sizing, high availability, and notification delivery.

A hosted option reduces the control-plane work. Grafana Cloud’s documented MySQL integration uses Prometheus MySQL Exporter and supplies dashboards plus 15 alert rules. You still manage the exporter, database credentials, firewall path, and the quality of the alert thresholds, while the hosted service handles more of the Prometheus and Grafana operation.

Decision factor Self-hosted Prometheus and Grafana Hosted Grafana integration
Operational ownership You patch, upgrade, back up, scale, and route alerts. The provider operates the hosted control plane; you still operate the exporter and database connection.
Network and credentials Metrics and credentials can remain inside your infrastructure. You must design a secure path from the exporter to the hosted service and protect API credentials.
Retention and query cost Controlled by your storage and retention settings. Governed by the hosted plan and its usage limits.
Collector and interval control Full control over enabled collectors and scrape timing. Still configurable at the exporter, with hosted defaults layered on top.
Portability Prometheus-compatible data and dashboards can be moved between installations. Convenient managed operation, with migration depending on export and retention options.

Choose the self-hosted route when data locality and customization matter more than maintenance time. Choose hosted monitoring when reducing control-plane administration is worth the service cost and network design.

Operate the setup after deployment

Monitoring is a service, not a one-time installation. Keep a short runbook containing the database version, exporter version, service account host, credential-file location, Prometheus target, firewall rule, enabled collectors, and alert recipients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Test an alert periodically so notification routing is known to work.
  • Review exporter and database logs after upgrades.
  • Recheck collector compatibility when moving between MySQL or MariaDB major versions.
  • Measure scrape duration and database load after changing intervals or collectors.
  • Rotate the exporter password using a planned maintenance step and verify the target returns to UP.
  • Back up Prometheus and Grafana configuration when those systems are self-hosted.

With a least-privilege account, a private exporter endpoint, verified Prometheus targets, and dashboards tied to concrete operating decisions, a Linux VPS can provide useful MySQL and MariaDB visibility without granting the monitoring process application-level access.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Database MonitoringGrafanaLinux VPSMariaDBMySQLmysqld_exporterPrometheus

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.