Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.4Mb
PDF (A4) - 31.5Mb
PDF (RPM) - 30.6Mb
EPUB - 7.8Mb
HTML Download (TGZ) - 7.6Mb
HTML Download (Zip) - 7.6Mb
HTML Download (RPM) - 6.5Mb
Eclipse Doc Plugin (TGZ) - 8.3Mb
Eclipse Doc Plugin (Zip) - 10.2Mb
Man Pages (TGZ) - 185.3Kb
Man Pages (Zip) - 298.0Kb
Info (Gzip) - 2.9Mb
Info (Zip) - 2.9Mb
Excerpts from this Manual

5.4.2 The Error Log

The error log contains information about mysqld startup and shutdown times, progress notes that occur during startup and shutdown, and 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 24.5, “Debugging and Porting MySQL”.

Interpretation of error logging options differs somewhat for Windows and Unix systems, so be sure to use the information appropriate to your system.

mysqld_safe may write messages to the error log if it is used to start mysqld. For example, when mysqld_safe notices abnormal mysqld exits, it 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. (For example, if invoked with the --syslog option, mysqld_safe arranges for the server's stderr to be sent to syslog, as described later.)

Error Logging on Windows

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

  • Without --log-error, mysqld writes error messages to the default log file.

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

  • The default log file is host_name.err in the data directory, unless the --pid-file option is specified. In that case, the default name is the PID file base name with a suffix of .err in the data directory. This default is used if --log-error is not given, or is given without naming a log file.

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

In addition, on Windows, the server by default writes events and error messages to the Windows Event Log within the Application log.

  • Entries marked as Error, 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.

If the server writes error output to a file, the log_error system variable indicates the error log file name.

Error Logging on Unix and Unix-Like Systems

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

  • Without --log-error, mysqld writes error messages to the console.

  • With --log-error[=file_name], mysqld writes error messages to an error log file. If no file is named, mysqld writes to the default log file. If a file is named, mysqld writes to it, creating it in the data directory unless an absolute path name is given to specify a different 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 file name from the entry causes the default log file to be used.

  • The default log file is host_name.err in the data directory. This default is used if --log-error is given without naming a log file.

If the server writes error output to a file, the log_error system variable indicates the error log file name.

If you specify --log-error in an option file in a [mysqld], [server], or [mysqld_safe] section, mysqld_safe finds and uses the option.

Using Syslog for the Error Log

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=file_name to mysqld_safe, and mysqld_safe will arrange for mysqld to write messages to a log file. To use syslog instead, specify the --syslog option.

Error Log Verbosity

The --log-warnings option or log_warnings system variable controls warning logging to the error log. The default value is enabled (1). To disable warning logging, set --log-warnings or log_warnings to 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 Section B.5.2.11, “Communication Errors and Aborted Connections”.

Flushing and Renaming the Error Log 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), the server closes and reopens the log file. To rename the file, do so manually before flushing. Flushing the logs then reopens a new file with the original file name. For example, to rename the file and create a new one, use the following commands (assuming a log file name of host_name.err):

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

On Windows, use rename rather than mv.

If the location of the error file is not writable by the server, the log-flushing operation will fail to create a new log file. For example, on Linux, the server might write the error log as /var/log/mysqld.log, where /var/log is owned by root and not writable by mysqld. For information about handling this case, see Section 5.4.7, “Server Log Maintenance”.

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


User Comments
Sign Up Login You must be logged in to post a comment.