All Products
Search
Document Center

Application Real-Time Monitoring Service:Permissions required for mysqld_exporter to access a MySQL database

Last Updated:Jan 23, 2024

To collect monitoring data from a MySQL database to Managed Service for Prometheus, you must have the read permissions on the database. This topic describes how to create a MySQL account for mysqld_exporter and grant minimum permissions to the account. This way, you can use Managed Service for Prometheus to monitor your MySQL database.

Create an account and grant permissions to the account

  1. Run the following command in the MySQL database to create an account for mysqld_exporter:

    CREATE USER 'mysqld_exporter'@'localhost' IDENTIFIED BY 'password';
    Note

    mysqld_exporter and password are a custom username and password. Replace them based on your needs.

  2. Run the following command to grant minimum permissions to the account:

    mysql> GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'mysqld_exporter'@'localhost' identified by 'password';    
    -- Add the read permissions on the performance_schema.* table. 
    mysql> GRANT SELECT ON performance_schema.* TO 'mysqld_exporter'@'localhost';
    mysql> FLUSH PRIVILEGES;

References

For information about how to collect monitoring data from a MySQL database to Managed Service for Prometheus, see Install and configure a MySQL exporter.