MySQL logging configuration¶
MySQL logging configuration is primarily handled through the my.ini configuration file. This file defines the paths and activation states for various types of logs, including the general query log, the slow query log, and the error log^[600-developer__database__mysql__mysql8-portable.md].
Configuration Parameters¶
The specific behavior of MySQL logging is controlled by several key directives within the [mysqld] section of the configuration file.
General Query Log¶
The general query log records all statements received by the server^[600-developer__database__mysql__mysql8-portable.md]. It is controlled by the general-log flag and the general_log_file path^[600-developer__database__mysql__mysql8-portable.md].
general-log=0
general_log_file="D:/JavaTool/database/mysql-8.0.13-winx64/mysql-general.log"
In standard configurations, the general log is often disabled by default (set to 0) to prevent performance degradation and excessive disk usage^[600-developer__database__mysql__mysql8-portable.md].
Slow Query Log¶
The slow query log is used to identify queries that take a long time to execute, which aids in performance optimization^[600-developer__database__mysql__mysql8-portable.md]. It is enabled using slow-query-log and its output is directed to the file specified by slow_query_log_file^[600-developer__database__mysql__mysql8-portable.md].
slow-query-log=1
slow_query_log_file="D:/JavaTool/database/mysql-8.0.13-winx64/mysql-slow.log"
Error Log¶
The error log records startup, shutdown, and critical error messages^[600-developer__database__mysql__mysql8-portable.md]. The destination for this log is specified by the log-error directive^[600-developer__database__mysql__mysql8-portable.md].
log-error="D:/JavaTool/database/mysql-8.0.13-winx64/mysql-error.log"
Related Concepts¶
- [[MySQL configuration]] (Derived from
my.ini) - [[Performance tuning]] (Related to
slow-query-log) - [[Data directory]] (Related to
datadir)
Sources¶
^[600-developer__database__mysql__mysql8-portable.md]