Database Reference
In-Depth Information
storage medium for changes to be sent to slave servers. The binary log is also used,
together with backup files, during data recovery operations.
Each log serves a different purpose and most can be turned on at your discretion, ena‐
bling you to use those that suit your administrative requirements. Each log can be
written to a file, and some can be written to other destinations. The error log can be
sent to your terminal or to the syslog facility. The general and slow query logs can be
written to a file, to a table in the mysql database, or both.
To control server logging, add lines to your server option file that specify the desired
types of logging. (Some settings can also be changed at runtime, as indicated later.) For
example, the following lines in a server option file send the error log to the err.log file
in the data directory, enable writing the general query and slow query logs to tables in
the mysql database, and enable writing the binary log to the /var/mysql-logs directory
using files having names beginning with binlog :
[mysqld]
log_error=err.log
log_output=TABLE
general_log=1
slow_query_log=1
log-bin=/var/mysql-logs/binlog
For filenames in options that produce log output to files, logfiles are written under the
data directory unless specified using full pathnames. The usual reason to use full path‐
names is to write logfiles to a filesystem different from the one containing the data
directory, a useful technique for dividing disk space use and I/O activity among physical
devices.
The rest of this section provides details specific to controlling individual logs. The ex‐
amples show the lines to include in your server option file to produce specific logging
behavior. For some ideas about using the logs for diagnostic or activity assessment pur‐
poses, see Recipe 22.6 .
For any log that you enable, see also Recipes 22.4 and 22.5 for log
maintenance techniques. Logs increase in size over time, so you'll
want to have a plan for managing them.
The error log
The error log cannot be disabled, but you can control where it's written. By default, on
Unix, the error output goes to your terminal on Unix or to host_name .err in the data
directory if you start the server using mysqld_safe . On Windows the default is
host_name .err in the data directory. To specify the error log filename, set the log_er
ror system variable.
Search WWH ::




Custom Search