Home » Performance » MySQL » How to set slow query log
How to set slow query log [message #1413] Wed, 13 June 2007 02:31 Go to next message
julian  is currently offline julian
Messages: 13
Registered: March 2007
Junior Member
Hi

I want to set slow query log which consists of all SQL statements that took more than long_query_time seconds to execute.

Now default value is set for long_query_time ie 10. Show variables shows


log_slow_queries - OFF

long_query_time - 10

I want to enable log_slow_queries and set long_query_time =1

I found in mysql manual to set slow query log as follows in my.cnf


mysqld]
set-variable=long_query_time=1
log-slow-queries=/var/log/mysql/log-slow-queries.log


You must create the file manually and change owners this way:

mkdir /var/log/mysql
touch /var/log/mysql/log-slow-queries.log
chown mysql.mysql -R /var/log/mysql


Even after changing this in my.cnf, the show Global variables shows as

log_slow_queries - OFF

long_query_time - 10

It looks like same before and the new value not set.


In my linux server, my.cnf settings are



[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable=long_query_time=1
log-slow-queries=/var/log/mysql/log-slow-queries.log

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib


[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


~
~
"/etc/my.cnf" 21L, 454C



Any one say how to find slow log queries. I'm using RHEL 5 and MySQL 5.0.22

thanks











Re: How to set slow query log [message #1414 is a reply to message #1413 ] Wed, 13 June 2007 08:49 Go to previous messageGo to next message
babuno5  is currently offline babuno5
Messages: 7
Registered: June 2007
Location: India
Junior Member

have u restarted the mysql server after making your changes in the my.cnf file
Re: How to set slow query log [message #1421 is a reply to message #1414 ] Thu, 14 June 2007 01:05 Go to previous messageGo to next message
julian  is currently offline julian
Messages: 13
Registered: March 2007
Junior Member
S . I restarted using command - service mysqld restart


General query log captures in mysqld.log.

slow query log only not enabled.

After restarting mysql server log_slow_queries=off

is there any other way to enable log_slow_queries

thanks
Re: How to set slow query log [message #1422 is a reply to message #1421 ] Thu, 14 June 2007 03:18 Go to previous message
babuno5  is currently offline babuno5
Messages: 7
Registered: June 2007
Location: India
Junior Member

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable=long_query_time=1
log-slow-queries=/var/log/mysql/log-slow-queries.log

well this is what i use for slow query log

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable=long_query_time=1
log_slow_queries=/var/log/mysql/log-slow-queries.log
Previous Topic:New server setup
Next Topic:lost connection to mysql server during query
Goto Forum:
  


Current Time: Thu Jul 9 21:53:41 EDT 2009

Total time taken to generate the page: 0.14145 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.