5.2.2 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.

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. (For example, if invoked with the
--syslog option,
mysqld_safe arranges for the server's
stderr to be sent to syslog,
as described later.)

Without --log-error,
mysqld writes error messages to
host_name.err
in the data directory.

With
--log-error[=file_name],
mysqld writes error messages to an error
log file. The server uses the named file if present, creating
it in the data directory unless an absolute path name is given
to specify a different directory. If no file is named, the
default name is
host_name.err
in the data directory.

With --console,
mysqld writes error messages to the
console, unless --log-error is
also given. If both options are present,
--console is ignored and has no
effect. Their order does not matter:
--log-error takes precedence
and error messages go to a log file. (Before MySQL 5.5.3, if
both options are given, the last one takes precedence.)

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.

With
--log-error[=file_name],
mysqld writes error messages to an error
log file. The server uses the named file if present, creating
it in the data directory unless an absolute path name is given
to specify a different directory. If no file is named, the
default name is
host_name.err
in the data directory.

Note

It is common for Yum or APT package installations to
configure the error log location to be under
/var/log with an entry like
log-error=/var/log/mysqld.log in a
server configuration file; removing the filename from the
entry reverts the error log location back to its default
setting, which is the data directory.

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

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.

As of MySQL 5.5.7, the server closes and reopens the log file.
To rename the file, 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:

Prior to MySQL 5.5.7, the server 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. On Windows, you cannot rename
the error log while the server has it open before MySQL 5.5.7.
To avoid a restart, flush the logs first to cause the server
to rename the original file and create a new one, then save
the renamed file. That also works on Unix, or you can use the
commands shown earlier.

No error log renaming occurs when the logs are flushed in any case
if the server is not writing to a named file.