Webmaster Help AwProfits
|
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jan 05, 2009, 10:55:13 PM

Login with username, password and session length

Children have never been very good at listening to their elders, but they have never failed to imitate them.


- James Baldwin

Welcome Guest - Register or Login Now to remove these advertisments


Registration is completely free and only takes a few minutes to signup !

|-   Entrepreneur Forum > Webmasters - Discuss Making Money Online > Website Design and Maintenance > Database
+   Mysql log slow queries
0 Members and 3 Guests are viewing this topic.
Pages: [1] Reply to Thread
Author Topic: Mysql log slow queries  (Read 446 times)
OfflineO_O
New Member
O_O is on a distinguished road
Joined: Oct 2007
Posts: 21



Beam me up

View O_O\s Profile
Canada
notepad Dec 10, 2007, 04:47:49 PM #1
how the heck do you turn this on?
I've tried turning on the option in the my.cnf and it doesn't work... the queries aren't logged.

how do you do it you do do it?


log_slow_queries=/var/log/slow-queries.log
long_query_time=2

I put that in my my.cnf and it did nothing..

Online~Dave~
Administrator
~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough
Joined: Jan 2006
Posts: 6186


Avatar of code4gol

Building a Foundation

View ~Dave~\s ProfileWWW
Gender: MaleGemini United States
notepad Dec 14, 2007, 10:49:02 PM #2
First, did you reboot mysql after editing the my.cnf ?

I think you have to use "set variable" before the long_query_time if I remember correctly...

ie: set-variable = long_query_time = 5

You're also setting your long query time to 2 seconds, most recommendations would be to set it to 5-10 seconds at least.

Latest Blog Post : Social Media Optimization for Social Media Marketing

Online~Dave~
Administrator
~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough
Joined: Jan 2006
Posts: 6186


Avatar of code4gol

Building a Foundation

View ~Dave~\s ProfileWWW
Gender: MaleGemini United States
notepad Dec 14, 2007, 11:14:22 PM #3
Your post got me thinking.... I've been having problems with the search query for this forum being too slow and timing out Apache, so I decided to log long queries to find out what was going on...

In my my.cnf file, I added the following lines (forget about my last post with the set-variable as that is no longer needed in mysql after version 3)...

Code:
log_slow_queries=/var/log/slow-queries.log
long_query_time=5

I restarted mysql and did a search and it timed out as usual, but nothing was logged and no log file was created. I assumed the mysql daemon would create the file /var/log/slow-queries.log but when I checked my mysql log by doing this...

tail -f /var/log/mysqld.log

I noticed the following error

Quote
071214 22:54:56  mysqld started
/usr/sbin/mysqld: File '/var/log/slow-queries.log' not found (Errcode: 13)
071214 22:54:56 [ERROR] Could not use /var/log/slow-queries.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.

OK, so mysql daemon *will not* create the log for you automatically like Apache does, so what you have to do is create the log, set permissions and owner like this...

Code:
touch /var/log/slow-queries.log
chmod 660 /var/log/slow-queries.log
chown mysql:root /var/log/slow-queries.log

The restart mysql and you will be able to get your long query log working fine !!!








Latest Blog Post : Social Media Optimization for Social Media Marketing

Pages: [1] Reply to Thread


Code4Gold Affiliate Entrepreneur Moneymaker Forum © 2006-2008 Resdaz Media LLC - All Rights Reserved

Forum Software Powered by SMF - © 2001-2008, Lewis Media. All Rights Reserved.