4

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
James Bailey
  • 498
  • 6
  • 19

1 Answers1

5

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;

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.

Community
  • 1
  • 1
Drew
  • 24,851
  • 10
  • 43
  • 78
  • Setting it from console worked!! I wonder why didn't it set `general_log` to `true` when added in `my.ini`?!! – Fr0zenFyr Oct 08 '16 at 06:45
  • @Fr0zenFyr did you restart the server? Is it the .ini that is actually picked up and used? (which can be hard to debug in person, let alone little comment boxes? :p) ... also I have a chat room [Campaigns](http://chat.stackoverflow.com/rooms/95290) people sometimes dump mysql questions in. No promises. – Drew Oct 08 '16 at 06:47
  • Also I wrote these two up in the Docs section [General](http://stackoverflow.com/documentation/mysql/5102/log-files/18052/general-query-log#t=201610080651188753838) and [Slow query](http://stackoverflow.com/documentation/mysql/5102/log-files#t=201610080651188753838) . As an aside, when I am testing whether a setting is picked up (mainly if the cnf or ini is in the right place in a directory), I test against an innocuous variable like the `verbosity` type variables (depending on your MySQL version). Test to see if the file change is picked up for that variable. – Drew Oct 08 '16 at 06:53
  • Hi - thanks for response. I'm sure about the `.ini` file i'm editing. I have successfully set up binary logging using same file (for backup/restore plans), so other settings are definitely being picked from there. Ohh! and yes, i did restart mysql service. – Fr0zenFyr Oct 08 '16 at 08:45