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 is in contrast with that of the binary log, for which statements are written after they are executed but before any locks are released. In addition, the query log may contain statements that only select data while such statements are never written to the binary log.
When using statement-based binary logging on a replication master server, statements received by its slaves are written to the query log of each slave. Statements are written to the query log of the master server if a client reads events with the mysqlbinlog utility and passes them to the server.
However, when using row-based binary logging, updates are sent as
row changes rather than SQL statements, and thus these statements
are never written to the query log when
binlog_format is
ROW. A given update also might not be written
to the query log when this variable is set to
MIXED, depending on the statement used. See
Section 16.1.2.1, “Advantages and Disadvantages of Statement-Based and Row-Based
Replication”, for more information.
Control the general query log at server startup as follows:
Before 5.1.6, the general query log destination is always a file. To enable the log, start mysqld with the
--log[=orfile_name]-l [option.file_name]As of MySQL 5.1.6, the destination can be a file or a table, or both. Start mysqld with the
--log[=orfile_name]-l [option to enable the general query log, and optionally usefile_name]--log-outputto specify the log destination (as described in Section 5.2.1, “Selecting General Query and Slow Query Log Output Destinations”).As of MySQL 5.1.12, as an alternative to
--logor-l, use--general_log[={0|1}]to specify the initial general query log state. In this case, the default general query log file name is used. With no argument or an argument of 1,--general_logenables the log. With an argument of 0, this option disables the log.As of MySQL 5.1.29, use
--general_log[={0|1}]to enable or disable the general query log, and optionally--general_log_file=to specify a log file name. Thefile_name--logand-loptions are deprecated.
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
To disable or enable the general query log or change the log file
name at runtime, use the global
general_log and
general_log_file system
variables. Set general_log to 0
(or OFF) to disable the log or to 1 (or
ON) to enable it. Set
general_log_file to specify the
name of the log file. If a log file already is open, it is closed
and the new file is opened.
When the general query log is enabled, the server writes output to
any destinations specified by the
--log-output option or
log_output system variable. If
you enable the log, the server opens the log file and writes
startup messages to it. However, further logging of queries to the
file does not occur unless the FILE log
destination is selected. If the destination is
NONE, the server writes no queries even if the
general log is enabled. Setting the log file name has no effect on
logging if the log destination value does not contain
FILE.
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, you can rename the file and create a new one by using the following commands:
shell>mvshell>host_name.loghost_name-old.logmysqladmin flush-logsshell>mvhost_name-old.logbackup-directory
On Windows, you cannot rename the general query log file while the server has it open before MySQL 5.1.3. You must stop the server, rename the file, and then restart the server to create a new log file.
As of MySQL 5.1.12, you can rename the general query log file at runtime by disabling the log:
SET GLOBAL general_log = 'OFF';
With the log disabled, rename the log file externally; for example, from the command line. Then enable the log again:
SET GLOBAL general_log = 'ON';
This method works on any platform and does not require a server restart.
The session sql_log_off variable
can be set to ON or OFF to
disable or enable general query logging for the current
connection.
The general query log should be protected because logged statements might contain passwords. See Section 6.1.2.3, “Passwords and Logging”.
This was on Windows Server 2008 using 32-bit MySQL version 5.1.49
Moving the logs out of that directory and into the root C: fixed the issue for me. All I can figure is the logs don't like the parentheses in (x86), I've seen this a couple times before.
Anyway if it helps anyone, my current working my.ini file on Windows now looks like this:
[mysqld]
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = "C:/slowquery.log"
#Set General Log
log = "C:/genquery.log"
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/"
Likly that something along this path is what you want
Example: Cleanup log:
I am logging into my database itself... but after 1 day, there will be about 180k queries of log. ( in a file, it would be 30MB per day <.<)
This script is an example to keep the table clean ;) even if you forgot it for a week or 2 you can cleanup even then ;)
You need to add an additional column (event_unix) and then you can use this script to keep the log clean... it will update the timestamp into a Unix-timestamp, delete the logs older than 1 day and then (i don't know why, but in my log, the event_time is setted into the actual time) update the event_time into Timestamp from event_unix... sounds a bit confusing, but it's working great :D Would use it as an event, but the event is disallowe the change from general_log...
Commands for the new column:
"
SET GLOBAL general_log = 'OFF';
RENAME TABLE general_log TO general_log_temp;
ALTER TABLE `general_log_temp`
ADD COLUMN `event_unix` int(10) NOT NULL AFTER `event_time`;
RENAME TABLE general_log_temp TO general_log;
SET GLOBAL general_log = 'ON';
#
cleanup script =>
SET GLOBAL general_log = 'OFF';
RENAME TABLE general_log TO general_log_temp;
UPDATE general_log_temp SET event_unix = UNIX_TIMESTAMP(event_time);
DELETE FROM `general_log_temp` WHERE `event_unix` < UNIX_TIMESTAMP(NOW()) - 86400;
UPDATE general_log_temp SET event_time = FROM_UNIXTIME(event_unix);
RENAME TABLE general_log_temp TO general_log;
SET GLOBAL general_log = 'ON';
##
Hope you like it ;)
Regards, S.K.