|< Day Day Up >|
10.6 Log and Status Files
The MySQL server can write information to several types of log files. The following list briefly describes each of these logs:
None of the preceding logs are enabled by default. You must enable them explicitly using appropriate startup options, which are shown in the following table. Each option may be given in --option or --option=file_name form. If no filename is specified, the server uses a default name, as shown in the table:
By default, each log file is created under the data directory unless you specify an absolute pathname. host_name stands for the server hostname. nnn in the name means that the server writes a numbered series of logs, creating a new log each time the server starts up or the logs are flushed.
The server also produces diagnostic messages about normal startups and shutdowns, as well as about abnormal conditions. On Windows, the server logs these messages to an error log, unless you invoke it with the --console option to send the messages to the console window. On Unix, the error log is set up by the mysqld_safe startup script, which then invokes the server with its output redirected to the error log. (That is, the server itself does not directly create the error log.) The default error log name is host_name.err in the data directory. (Older Windows servers use the name mysql.err instead.)
All logs are written in text format except for the binary log which, as the name implies, is in binary format. Text logs can be viewed using any program capable of displaying text files. For the slow query log, another approach is to use the mysqldumpslow utility; it can summarize the log contents. To view the binary log, use the mysqlbinlog utility.
On Unix, the server records its process ID in a PID file, for use by other programs that need to send the server a signal. (Unix processes send signals to each other using process ID values.) The default PID filename is host_name.pid in the data directory. The name and location can be changed with the --pid-file=file_name option.
Unix servers create a Unix socket file so that local clients can establish socket connections. By default, this file is /tmp/mysql.sock. A different filename can be specified by starting the server with the --socket option. If you change the location, client programs also need to be started with --socket so that they know where the socket file is located.
|< Day Day Up >|