Activities

January 2010
M T W T F S S
« Dec   Feb »
 123
45678910
11121314151617
18192021222324
25262728293031

Enable querry log on MySQL

I need to trace out what are happening on mysql when my application is running.

This is extremely useful for finding the lengthy sql query. This would help us to get an idea about which queries are to be taken for optimization which will cause the mysql performance.

This technique will work only the latest version of Mysql Say 5.3.1 or later.
login to mysql console,then execute

SET GLOBAL general_log = 'ON';

This command will generate a file on your mysql data directory and increasing very rapidly depending on the sql executed. Pls use it only for tracing/analyzing the issues only and turn off it once checking is finished. This command will turn off this logging

SET GLOBAL general_log = 'Off';

Enabling the slow query log

vi /etc/my.cnf
long_query_time = 0
slow_query_log = 1
slow_query_log_file=/var/log/slowlog.query.log
#touch /var/log/slowlog.query.log && chown -R mysql.mysql /var/log/slowlog.query.log

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>