Slow query logging can be easily enabled by following the below mentioned steps:
Step 1:
You need to edit the file "/etc/my.cnf" and place the following code in it.
log-slow-queries=/var/lib/mysql/slow.log long_query_time = 6Note: Dont forget to take the backup of "my.cnf".
The first line will enable the slow query logging and specifies the path where the log is to be saved. The second line will set the criteria for slow queries. That is queries that takes more then 6 seconds will be considered as slow queries.
Step 2:
Now after updating "my.cnf" you need to restart mysql. This can be done using any of the below mentioned shell commands.
service mysqld restartOR
/etc/init.d/mysqld restartStep 3:
After restarting you need to flush mysql logs in order to get the file automatically created. This can be done by using the below mentioned shell command:
mysqladmin flush-logsWell guys i guess thats it, you have successfully enabled slow query logging in mysql. For any queries that you may have, feel free to comment.
No comments:
Post a Comment