Server Monitoring2 min read

    How to Monitor MySQL Database

    Share

    Overview

    The MySQL integration allows you to monitor your MySQL database performance in real time. Xitoring tracks key performance indicators like query throughput, connection counts, replication status, CPU and memory usage — all visible from your dashboard with customizable alerts.

    What Can It Monitor?

    • CPU Usage — Database server CPU utilization
    • Memory Usage — RAM consumed by MySQL processes
    • Connections — Active and total connection counts
    • Queries per Second — Rate of SELECT, INSERT, UPDATE, DELETE operations
    • Slow Queries — Count of queries exceeding the slow query threshold
    • Replication Lag — Seconds behind master in replica setups
    • InnoDB Buffer Pool — Hit ratio and usage statistics
    • Table Locks — Lock wait times and deadlock detection
    • Uptime — How long the MySQL server has been running

    Prerequisites

    1. Enable Performance Schema

    Add the following to your MySQL configuration file under the [mysqld] block:

    [mysqld]
    performance_schema=ON
    

    Restart MySQL:

    sudo systemctl restart mysqld
    

    Verify it is enabled:

    SHOW VARIABLES LIKE 'performance_schema';
    

    2. Create a Monitoring User

    Create a dedicated user for Xitogent (do not use root):

    CREATE USER 'xitoring'@'%' IDENTIFIED BY '{your_password}';
    

    For MySQL 8+, use native password authentication:

    CREATE USER 'xitoring'@'%' IDENTIFIED WITH mysql_native_password BY '{your_password}';
    

    3. Grant Required Privileges

    For MySQL 5.6 / 5.7:

    GRANT REPLICATION CLIENT ON *.* TO 'xitoring'@'%' WITH MAX_USER_CONNECTIONS 5;
    

    For MySQL 8+:

    GRANT REPLICATION CLIENT ON *.* TO 'xitoring'@'%';
    ALTER USER 'xitoring'@'%' WITH MAX_USER_CONNECTIONS 5;
    

    Then grant process and performance schema access:

    GRANT PROCESS ON *.* TO 'xitoring'@'%';
    GRANT SELECT ON performance_schema.* TO 'xitoring'@'%';
    

    Verify the user can connect:

    mysql -u xitoring --password={your_password} -e "show status" | \
    grep Uptime && echo "MySQL user - OK" || echo "Cannot connect to MySQL"
    

    How to Activate the Integration

    Run the Xitogent CLI:

    xitogent integrate
    

    Select MySQL from the list. You will be prompted for:

    • MySQL host (typically 127.0.0.1)
    • MySQL port (default: 3306)
    • Username and password for the monitoring user

    The config file is created at /etc/xitogent/integrations/mysql_integration.conf.

    Windows note: The MySQL integration supports environments where MySQL, MySQL Shell, and ODBC Connector are installed via the official MySQL package. WAMP and XAMPP are not yet supported.

    Setting Up Triggers

    Available trigger parameters:

    • CPU Usage / Memory Usage
    • Connections / Queries per Second
    • Slow Queries / Replication Lag
    • InnoDB Buffer Pool metrics
    • Uptime

    Navigate to Triggers on your server page, select MySQL, choose a metric, and configure thresholds and notification channels.

    Tips

    • Always create a dedicated monitoring user with minimal privileges
    • Enable performance_schema for the most comprehensive metrics
    • Monitor Slow Queries to catch inefficient queries early
    • Use Replication Lag alerts in primary-replica setups to detect sync issues