MySQL – How to Log All Queries into a Log File

logMySQL

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…

Best Answer

[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.