How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

February 28, 2012

MYSQL slow queries log

Filed under: Linux — Tags: , , — admin @ 5:18 pm

MySQL has built-in functionality that allows you to log SQL queries to a file , You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable.
* To enable slow Query Log only
log-slow-queries = /var/log/mysql/mysql-slow.log
long_query_time = 1

The minimum and default values of long_query_time are 1 and 10, respectively.

* To enable full Log Query
log=/var/log/mysqldquery.log
This will log all queries on your mysqld.

Selecting Queries to Optmize
– The slow query log
– Logs all queries that take longer than long_query_time
– Can also log all querie s that don’t use indexes with
–log-queries-not-using-indexes
– To log slow administatve commands use
–log-slow-admin-statements
– To analyze the contents of the slow log use
mysqldumpslow

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress