This documentation is for an older version. If you're using the most current version, select the documentation for that version with the version switch in the upper right corner of the online documentation, or by downloading a newer PDF or EPUB file.

5.4.1 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 exits abnormally. The trace can be used to determine where mysqld exited. See Section 21.3, “Debugging and Porting MySQL”.

If mysqld_safe is used to start mysqld and mysqld exits abnormally, mysqld_safe notices this, restarts mysqld, and writes a mysqld restarted message to the error log.

In the following discussion, console means stderr, the standard error output; this is your terminal or console window unless the standard error output has been redirected.

On Windows, the --log-error, --pid-file, and --console options affect error logging:

In addition, on Windows, the server writes events and error messages to the Windows Event Log within the Application log. Entries marked as Warning and Note are written to the Event Log, but not informational messages such as information statements from individual storage engines. These log entries have a source of MySQL. You cannot disable writing information to the Windows Event Log.

On Unix and Unix-like systems, mysqld writes error log messages as follows:

At runtime, log_error system variable indicates the error log file name if error output is written to a file.

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), it renames the current log file with the suffix -old, then creates a new empty log file. Be aware that a second log-flushing operation thus causes the original error log file to be lost unless you save it under a different name. For example, you can use the following commands to save the file:

shell> mysqladmin flush-logs
shell> mv host_name.err-old backup-directory

If the server is not writing to a named file, no error log renaming occurs when the logs are flushed.

If you use mysqld_safe to start mysqld, mysqld_safe arranges for mysqld to write error messages to a log file. If you specify a file name using --log-error to mysqld_safe or mysqld, that file name is used. Otherwise, mysqld_safe uses the default error log file.

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. See Section B.5.2.11, “Communication Errors and Aborted Connections”.