James Bailey James Bailey - 8 months ago 48
MySQL Question

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
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
log-output = FILE
general-log = 1


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;

enter image description here

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;