Sunday, May 8, 2016

Enabled general and slowquery log in xampp

Tags


Ever wonder how to enabled general and slowquery log in xampp? It's easy!

First, go to my.ini (You can find this in C:\xampp\mysql\bin)

Next, write this into my.ini

-------------------------------------------------------------------------
log_error = "mysql_error.log"
general_log_file        = "mysql_general.log"
general_log             = 1
slow_query_log = 1
slow_query_log_file = "C:/xampp/log_file/slowquery.log"
long_query_time = 0.1
--------------------------------------------------------------------------
Refer below images for better understanding.


For your information
1) mysql_general.log  = Name of the file, you can change to any name that you want

2) C:/xampp/log_file/slowquery.log = This path vary on where you want to store your slowquery.log

3) long_query_time = If a query takes longer than this many seconds, the server increments the slow_queries status variable. If the slow query log is enabled, the query is logged to the slow query log file. More info here

After that, restart apache and mysql (Just stop and start if your apache and mysql already start before you edit my.ini)



Lastly, you should be able to see mysql_general.log inside C:\xampp\mysql\data & slowquery.log inside the folder that you just set just now.

mysql_general.log


slowquery.log

If you want to check the execution time of the query, this link will definitely help you
Check execution time of query


EmoticonEmoticon