Prepare MySQL database configuration

In this milestone, you prepare the MySQL database configuration required for monitoring. This includes creating a dedicated monitoring user account with the necessary permissions and gathering the connection details needed for Grafana.

Creating a dedicated monitoring user with minimal required privileges follows security best practices and ensures that the monitoring system has only the access it needs to collect metrics and logs.

Prerequisites:

  • Check if the MySQL server is up and running.
  • Make sure that your firewall is open for MySQL server (default port is 3306).

To prepare your MySQL database configuration, complete the following steps:

  1. Connect to your MySQL server as an administrative user:

    Bash
    mysql -u root -p
  2. Create a dedicated monitoring user for Grafana.:

    SQL
    CREATE USER 'grafanaReader' IDENTIFIED BY 'password';
  3. Grant the necessary privileges for monitoring:

    SQL
    GRANT SELECT ON performance_schema.* TO 'grafanaReader';
  4. Exit the MySQL client:

    SQL
    EXIT;
  5. Test the monitoring user connection:

    Bash
    mysql -u grafanaReader -p -e "SHOW STATUS LIKE 'Uptime';"

In the next milestone, you’ll add the MySQL data source to your Grafana Cloud instance.

More to explore (optional)

At this point in your journey, you can explore the following paths:

Adding data sources to Grafana (video)

Data source plugins for Grafana


page 4 of 9