The Error Log
The error log contains information indicating when mysqld was started and stopped and also any critical errors that occur while the server is running. If mysqld notices a table that needs to be automatically checked or repaired, it writes a message to the error log.
On some operating systems, the error log contains a stack trace if mysqld dies. The trace can be used to determine where mysqld died. See MySQL Internals: Porting.
You can specify where mysqld writes the error log with the --log-error[=
option. If the option is given with no file_name
]file_name
value, mysqld uses the name
by default. The server creates the file in the data directory unless an absolute path name is given to specify a different directory.
host_name
.err
If you do not specify --log-error
, or (on Windows) if you use the --console
option, errors are written to stderr
, the standard error output. Usually this is your terminal.
On Windows, error output is always written to the error log if --console
is not given.
In addition, on Windows, events and error messages are written to the Windows Event Log within the Application log. Entries marked as Warning
and Note
are written to the Event Log, but informational messages (such as information statements from individual storage engines) are not copied to the Event Log. The log entries have a source of MySQL. You cannot disable writing information to the Windows Event Log.
If you flush the logs using FLUSH LOGS
or mysqladmin flush-logs and mysqld is writing the error log to a file (for example, if it was started with the --log-error
option), the server closes and reopens the log file. To rename the file, you can do so manually before flushing. Then flushing the logs reopens a new file with the original file name. For example, you can rename the file and create a new one using the following commands:
shell>mv
shell>host_name
.errhost_name
.err-oldmysqladmin flush-logs
shell>mv
host_name
.err-oldbackup-directory
On Windows, use rename rather than mv.
No error log renaming occurs when the logs are flushed if the server is not writing to a named file.
If you use mysqld-safe to start mysqld, mysqld_safe arranges for mysqld to write error messages to a log file or to syslog
mysqld_safe has three error-logging options, --syslog
, --skip-syslog
, and --log-error
. The default with no logging options or with --skip-syslog
is to use the default log file. To explicitly specify use of an error log file, specify --log-error=
to mysqld_safe, and mysqld_safe will arrange for mysqld to write messages to a log file. To use file_name
syslog
instead, specify the --syslog
option.
If you specify --log-error
in an option file in a [mysqld]
, [server]
, or [mysqld_safe]
section, mysqld_safe will find and use the option.
If mysqld-safe is used to start mysqld and mysqld dies unexpectedly, mysqld_safe notices that it needs to restart mysqld and writes a restarted mysqld
message to the error log.
The --log-warnings
option or log_warnings
system variable can be used to control warning logging to the error log. The default value is enabled (1). Warning logging can be disabled using a value of 0. If the value is greater than 1, aborted connections are written to the error log, and access-denied errors for new connection attempts are written. See "Communication Errors and Aborted Connections".