Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Mysql 5.6.12 under Wamp server environment. Now I want to log All queries into ".log" file, the queries which are running by PHP or from PHPMyAdmin, I want to log them...

share|improve this question
up vote 10 down vote accepted
[mysqld]
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = /usr/log/slowquery.log
log_queries_not_using_indexes = 1

#Set General Log
general_log = on
general_log_file=/usr/log/general.log

Note that enabling general_log on a production server has overhead you should avoid it. You can check problematic queries from slow log.

share|improve this answer
1  
For me, I had to use "general_log = 1" instead of "general_log = on". – GuyPaddock Dec 22 '14 at 0:09
    
Worked on Wamp Server, using mysql 5.6.7. The only thing I had to change were the paths to tje files, in my case, C:\wamp\logs\mysql_query.log . – mOrSa Mar 19 '15 at 16:07
    
Wonderful answer, plus one and thank you. – ehime Feb 29 at 18:08

If you use these two lines in my.cnf, I find that it works fine. This will log all queries to the server, from any source, not just PHP/PHPMyAdmin. Paul...

[mysqld]

general_log     = on
general_log_file=/users/ugrad/linehanp/mydb/logfile.txt

Be careful though - enabling the general log can place a heavy load on your server. To be used sparingly for short periods/debugging only.

share|improve this answer
    
Thanks Man.... It solve the problem. :) – Qazi Mar 31 '14 at 10:21
    
For me, I had to use "general_log = 1" instead of "general_log = on". – GuyPaddock Dec 22 '14 at 0:09
    
@GuyPaddock what version of MySQL are you using? – Vérace Dec 22 '14 at 17:29

Since this is the type of thing you probably only want to do temporarily, it may be useful to do this from the shell instead of via the config file:

> set global general_log_file = "/var/log/mysql/queries.log";
> set global general_log = "ON";
[wait some time, hit some pages, whatever]
> set global general_log = "OFF";
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.