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 Alloy.
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.
To prepare your MySQL database configuration, complete the following steps:
Connect to your MySQL server as an administrative user:
mysql -u root -pCreate a dedicated monitoring user for Grafana Alloy:
CREATE USER 'alloy_monitor'@'localhost' IDENTIFIED BY 'secure_password';Grant the necessary privileges for monitoring:
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'alloy_monitor'@'localhost'; GRANT SELECT ON performance_schema.* TO 'alloy_monitor'@'localhost';Apply the privilege changes:
FLUSH PRIVILEGES;Exit the MySQL client:
EXIT;Test the monitoring user connection:
mysql -u alloy_monitor -p -e "SHOW STATUS LIKE 'Uptime';"Note your MySQL connection details for the next milestone:
- Hostname:
localhost(or your MySQL server hostname) - Port:
3306(or your custom MySQL port) - Username:
alloy_monitor - Password: The password you set for the monitoring user
- Database: Leave empty for monitoring all databases
- Hostname:
In the next milestone, you configure Grafana Alloy with the MySQL monitoring settings.
