docs/sources/datasources/mysql/troubleshooting/index.md
This document provides solutions to common issues you may encounter when configuring or using the MySQL data source in Grafana.
These errors occur when Grafana cannot establish or maintain a connection to the MySQL server.
Error message: "dial tcp: connection refused" or "Could not connect to MySQL"
Cause: Grafana cannot establish a network connection to the MySQL server.
Solution:
3306.bind-address setting in your MySQL configuration.Error message: "Connection timed out" or "I/O timeout"
Cause: The connection to MySQL timed out before receiving a response.
Solution:
wait_timeout setting in MySQL if connections are timing out during idle periods.Error message: "TLS handshake failed" or "x509: certificate verify failed"
Cause: There is a mismatch between the TLS settings in Grafana and what the MySQL server supports or requires.
Solution:
Error message: "Connection reset by peer" or "EOF"
Cause: The MySQL server closed the connection unexpectedly.
Solution:
max_connections setting on the MySQL server to ensure it isn't being exceeded.wait_timeout and interactive_timeout settings in MySQL aren't set too low.wait_timeout.These errors occur when there are issues with authentication credentials or permissions.
Error message: "Access denied for user 'username'@'host'" or "Authentication failed"
Cause: The authentication credentials are invalid or the user doesn't have permission to connect from the Grafana server's host.
Solution:
Verify that the username and password are correct.
Check that the user exists in MySQL and is enabled.
Ensure the user has permission to connect from the Grafana server's IP address. MySQL restricts access based on the connecting host:
SELECT user, host FROM mysql.user WHERE user = 'your_user';
If necessary, create a user that can connect from the Grafana server:
CREATE USER 'grafana'@'grafana_server_ip' IDENTIFIED BY 'password';
If using the mysql_native_password authentication plugin, ensure it's enabled on the server.
Error message: "Access denied for user 'username'@'host' to database 'dbname'"
Cause: The authenticated user doesn't have permission to access the specified database.
Solution:
Verify that the database name is correct in the data source configuration.
Ensure the user has the required permissions on the database:
GRANT SELECT ON your_database.* TO 'grafana'@'grafana_server_ip';
FLUSH PRIVILEGES;
For production environments, grant permissions only on specific tables:
GRANT SELECT ON your_database.your_table TO 'grafana'@'grafana_server_ip';
Error message: "Authentication plugin 'auth_pam' cannot be loaded" or cleartext password errors
Cause: PAM (Pluggable Authentication Modules) authentication requires cleartext password transmission.
Solution:
These errors occur when there are issues with query syntax or configuration.
Error message: "Could not find time column" or time series visualization shows no data
Cause: The query doesn't return a properly formatted time column for time series visualization.
Solution:
time when using the Time series format.$__time() macro to convert your date column: $__time(your_date_column).DATETIME, TIMESTAMP, DATE) or contains Unix epoch values.ORDER BY.Error message: "Error parsing query" or macros appear unexpanded in the query
Cause: Grafana macros are being used incorrectly.
Solution:
$__timeFilter(column) not $_timeFilter(column).$__timeFilter(\time-column`)`.Cause: Time series data appears shifted or doesn't align with expected times.
Solution:
Store timestamps in UTC in your database to avoid timezone issues.
Time macros ($__time, $__timeFilter, etc.) always expand to UTC values.
Set the Session Timezone in the data source configuration to match your data's timezone, or use +00:00 for UTC.
If your timestamps are stored in local time, convert them to UTC in your query:
SELECT
CONVERT_TZ(your_datetime_column, 'Your/Timezone', 'UTC') AS time,
value
FROM your_table
Error message: "Result set too large" or browser becomes unresponsive
Cause: The query returns more data than can be efficiently processed.
Solution:
$__timeFilter(column) to limit data to the dashboard time range.AVG, SUM, COUNT) with GROUP BY instead of returning raw rows.LIMIT clause to restrict results: SELECT ... LIMIT 1000.$__timeGroup() macro to aggregate data into time intervals.Error message: "You have an error in your SQL syntax" followed by specific error details
Cause: The SQL query contains invalid syntax.
Solution:
`table`, `select`.$variable or ${variable}.Error message: "Unknown column 'column_name' in 'field list'"
Cause: The specified column doesn't exist in the table or is misspelled.
Solution:
`column-name`.These issues relate to slow queries or high resource usage.
Cause: Queries take a long time to execute.
Solution:
Reduce the dashboard time range to limit data volume.
Add indexes to columns used in WHERE clauses and time filters:
CREATE INDEX idx_time ON your_table(time_column);
Use aggregations instead of returning individual rows.
Increase the Min time interval setting to reduce the number of data points.
Review the query execution plan using EXPLAIN to identify bottlenecks:
EXPLAIN SELECT * FROM your_table WHERE time_column > NOW() - INTERVAL 1 HOUR;
Error message: "Too many connections" or "Connection pool exhausted"
Cause: Too many concurrent connections to the database.
Solution:
Increase the Max open connection limit in the data source configuration.
Enable Auto (max idle) to automatically manage idle connections.
Reduce the number of panels querying the same data source simultaneously.
Check for long-running queries that might be holding connections.
Increase the max_connections setting in MySQL if necessary:
SHOW VARIABLES LIKE 'max_connections';
SET GLOBAL max_connections = 200;
Error message: "Query execution was interrupted" or "Lock wait timeout exceeded"
Cause: The query takes too long and exceeds the configured timeout.
Solution:
The following issues don't produce specific error messages but are commonly encountered.
Cause: Variable queries return unexpected results or errors.
Solution:
Cause: Data formatting or type conversion issues.
Solution:
SELECT value AS metric.NULL values that might affect aggregations.FILL option in $__timeGroup() macro to handle missing data points.Cause: Queries fail when tables or databases contain reserved words or special characters.
Solution:
`my-database`.`my-table`.Error message: "An unexpected error happened"
Cause: A general error occurred that doesn't have a specific error message.
Solution:
If you continue to experience issues after following this troubleshooting guide:
When reporting issues, include: