Internet Marketing Forum

Internet Marketing Forum


For Webmasters and Entrepreneurs
|
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2012, 02:57:17 PM

Login with username, password and session length

We can't solve problems by using the same kind of thinking we used when we created them.


- Albert Einstein

|-   Internet Marketing Forum > Online Business Discussions > Website Design and Maintenance > Database
+  

Mysql log slow queries

0 Members and 1 Guest are viewing this topic.
Pages: [1] Reply to Thread
Author Topic: Mysql log slow queries  (Read 1760 times)
OfflineO_O
Beginner
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..

OfflineCode4Gold
Administrator
Code4Gold is a jewel in the roughCode4Gold is a jewel in the roughCode4Gold is a jewel in the roughCode4Gold is a jewel in the rough
Joined: Jan 2006
Posts: 6215


Avatar of Code4Gold

Administrator

View Code4Gold\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 : 8 Tips for Creating a Marketing Buzz

OfflineCode4Gold
Administrator
Code4Gold is a jewel in the roughCode4Gold is a jewel in the roughCode4Gold is a jewel in the roughCode4Gold is a jewel in the rough
Joined: Jan 2006
Posts: 6215


Avatar of Code4Gold

Administrator

View Code4Gold\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 : 8 Tips for Creating a Marketing Buzz

Summer Savings! $7.49 .com domains at GoDaddy.com!
Pages: [1] Reply to Thread


Code4Gold Internet Marketing Forum © 2006-2011 Resdaz Media LLC - All Rights Reserved
Forum Software Powered by SMF - © 2001-2008, Lewis Media. All Rights Reserved.