The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld.
mysqld writes statements to the query log in the order that it receives them, which might differ from the order in which they are executed. This logging order contrasts to the binary log, for which statements are written after they are executed but before any locks are released. (Also, the query log contains all statements, whereas the binary log does not contain statements that only select data.)
To enable the general query log, start mysqld
with the
--log[=
or file_name]-l [
option.
file_name]
If the general query log file is enabled but no name is specified,
the default name is
and
the server creates the file in the same directory where it creates
the PID file. If a name is given, the server creates the file in
the data directory unless an absolute path name is given to
specify a different directory.
host_name.log
Server restarts and log flushing do not cause a new general query log file to be generated (although flushing closes and reopens it). On Unix, to rename the file and create a new one, use the following commands:
shell>mvshell>host_name.loghost_name-old.logmysqladmin flush-logsshell>mvhost_name-old.logbackup-directory
On Windows, you cannot rename a log file while the server has it
open before MySQL 5.0.17. You must stop the server, rename the
file, and then restart the server to create a new log file. As of
5.0.17, this applies only to the error log. However, a stop and
restart can be avoided by using
FLUSH LOGS, which
causes the server to rename the error log with an
-old suffix and open a new error log.
The general query log should be protected because logged statements might contain passwords. See Section 6.1.2.3, “Passwords and Logging”.