sql - How do I enable the MySQL slow query log? -


this question has answer here:

my mysql version details are

  1. server: localhost via unix socket
  2. software: mysql
  3. software version: 5.0.96-community-log - mysql community edition (gpl)
  4. protocol version: 10

how enable mysql slow query log?

version 5.1.6 , above:

1. enter mysql shell , run following command:

set global slow_query_log = 'on';

2. enable other desired options. here common examples:

log details queries expected retrieve rows instead of using index:

   set global log_queries_not_using_indexes = 'on' 

set path slow query log:

  set global slow_query_log_file ='/var/log/mysql/slow-query.log'; 

set amount of time query needs run before being logged:

   set global long_query_time = '20';      (default 10 seconds) 

3. confirm changes active entering mysql shell , running following command:

show variables '%slow%'; 

versions below 5.1.6:

  1. edit /etc/my.cnf file favorite text editor vi /etc/my.cnf

  2. add following line under “[mysqld]” section. feel free update path log file whatever want:

    log-slow-queries=/var/log/mysql/slow-query.log

3. enable additional options needed. here same commonly used examples above:

set amount of time query needs run before being logged:

  `long_query_time=20   (default 10 seconds)` 

log details queries expected retrieve rows instead of using index:

 `log-queries-not-using-indexes` 

4. restart mysql service:

service mysqld restart 

5. confirm change active entering mysql shell , running following:

show variables '%slow%'; 

update:1

according mysql docs, error #1193 occurs when use wrong code sqlstate.

message: unknown system variable %s 

and, can see on same page, sqlstate 99003 not defined.

refer link:

http://dev.mysql.com/doc/refman/5.5/en/slow-query-log.html

http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -