MySQL Error Log
Server errors, warnings, startup/shutdown messages, and diagnostic information
Quick Facts
Default Path (Linux)
/var/log/mysql/error.logDocker
stderrDefault Format
text
JSON Native
Yes (since 8.0.4)
Rotation
manual or logrotate
Log Example
Default format: Default Text Format
Example Log Entrylog
2025-12-20T14:32:18.123456Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.Structure:
timestamp thread_id [severity] [error_code] messagePaths by Platform
Debian / Ubuntu
/var/log/mysql/error.logRHEL / CentOS
/var/log/mysqld.logAvailable Formats
Default Text Format
Default
Example:
2025-12-20T14:32:18.123456Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.Structure:
timestamp thread_id [severity] [error_code] messageJSON Format
Native
Config Required
Available since version 8.0.4
Example:
{"timestamp":"2025-12-20T14:32:18.123456Z","thread":0,"severity":"Warning","error_code":"MY-010068","subsystem":"Server","message":"CA certificate ca.pem is self signed."}Structure:
JSON object with structured fieldsFields Reference
| Field | Type | Description | Example |
|---|---|---|---|
timestamp | datetime | When the event occurred | 2025-12-20T14:32:18.123456Z |
thread | integer | Thread ID | 0 |
severity | string | Error severity level | Warning |
error_code | string | MySQL error code | MY-010068 |
subsystem | string | Server subsystem | Server |
message | string | Error message | CA certificate ca.pem is self signed. |
Parsing Patterns
Grok Patterns
text:
%{TIMESTAMP_ISO8601:timestamp}Z %{NUMBER:thread} \[%{WORD:severity}\] \[%{DATA:error_code}\] \[%{WORD:subsystem}\] %{GREEDYDATA:message}Collector Configurations
logstashruby
1filter {2 grok {3 match => { "message" => "%{TIMESTAMP_ISO8601:timestamp}Z %{NUMBER:thread} \[%{WORD:severity}\] \[%{DATA:error_code}\] \[%{WORD:subsystem}\] %{GREEDYDATA:mysql_message}" }4 }5}Configuration
Enable Logging
Error log is enabled by default; configure path and format
/etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
log_error = /var/log/mysql/error.log
log_error_verbosity = 2 # 1=errors, 2=+warnings, 3=+notesEnable Json
Enable JSON error logging (MySQL 8.0.4+)
[mysqld]
log_error = /var/log/mysql/error.log
log_error_services = 'log_filter_internal; log_sink_json'Log Rotation
Tool: logrotate | Config: /etc/logrotate.d/mysql
/etc/logrotate.d/mysql
/var/log/mysql/error.log {
daily
rotate 7
missingok
create 640 mysql adm
compress
sharedscripts
postrotate
mysqladmin --defaults-file=/etc/mysql/debian.cnf flush-logs error
endscript
}Use Cases
Startup issues
Track server initialization problems
severity
message
Replication errors
Monitor replication health
error_code
message
Troubleshooting
Tested On
v8.4.0 on Ubuntu 24.04
mysql_dba - 2025-12-10
Last updated: 2025-12-10 by mysql_dba
2 contributors134 upvotes
Validated
Community Discussions
Help improve this documentation
Found an error or want to add more examples? Contributions are welcome!