简体   繁体   中英

can't enable MySql general query log file on wamp running mysql 5.6

I am having trouble activating a general query log file in WAMP I have viewed many threads and can't seem to get it to write a log.

I have tried both good queries and bad queries to try to trip the log.

Any suggestions?

This is my my.ini

# The MySQL server
[wampmysqld]
port        = 3306
socket      = /tmp/mysql.sock
key_buffer_size = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
basedir=c:/wamp/bin/mysql/mysql5.6.17
log-error=c:/wamp/logs/mysql.log
datadir=c:/wamp/bin/mysql/mysql5.6.17/data
log-output = FILE
general-log = 1
general_log_file=C:/wamp/logs/general-query.log

You have a typo in general-log . It should be general_log

And then a mysql restart.

And check your variables, after a restart such as

select @@general_log; -- 0 (that means OFF). 1 is ON.
select @@general_log_file; -- GUYSMILEY.log
select @@datadir; -- C:\ProgramData\MySQL\MySQL Server 5.6\Data\
select @@version; -- 5.6.31-log

To set a dynamic variable to override a cnf or ini file setting, do something similar to:

set GLOBAL general_log=1;

在此输入图像描述

Remember that it is datadir , not basedir . You may need to open up the viewing of hidden folders on Windows to see the \\ProgramData if that is where you datadir points.

And lastly, you don't need to trick it with an error sql statement. The General Query Log is for all queries.

For a screenshot view of it, see This Answer . Remember, it is for all queries. So turn it off, make a copy, delete, turn back on, it regenerates. Don't forget too that having the General Log activated in production slows down performance.

Also, see this answer from Gryphius.

Edit (per your question in comments).

Changes to dynamic variables are fleeting if not mirrored in cnf or ini settings. Meaning, they are reset upon mysql restarting.

I don't know a way to turn off Error logging nor would I probably want to. Errors are infrequent and knowledge of them is quite important. So the below should satisfy 3 of your 4 curiosities:

show variables like '%error%';
show variables like '%slow%';

log_error -- string for filename

slow_query_log -- set to 'ON' or 1, 'OFF' or 0
slow_query_log_file; --- string for filename

Then there is always show variables;

More on the slow query log . If you set the long_query_time high enough, it will effectively filter out more noise. It is in seconds, from 0 to 10. And a Percona article though dated.

select @@long_query_time;
+-------------------+
| @@long_query_time |
+-------------------+
|         10.000000 |
+-------------------+

Note, I can't seem to set the above with a SET GLOBAL stmt. So it appears to be a setting only for the cnf or ini file. But you can do the following:

select @@slow_query_log; -- to see current value
select @@slow_query_log_file; -- to see current value (file in datadir)
select @@datadir; -- to see current value

set global slow_query_log=0; -- Turn Off
-- make a backup of it with a move and rename (See Note1) to a folder below datadir
set global slow_query_log=1; -- Turn it back On (new empty file is created)

Note1: Image of file copied, renamed at Note1 point-in-time above. Image Here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM