The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Turn on MySQL query logging

Discussion in 'General Discussion' started by esolutions, Jan 19, 2007.

  1. esolutions

    esolutions Member

    Joined:
    Aug 16, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Hi, I have a cPanel server that has been running great until recently when the mysqld process begun to produce very high load averages at times. I want to turn on query logging and see what is going on, but I haven't been able to.

    I have added a line to /etc/my.cnf under the [mysql.server] section that reads 'log=/var/log/m.log'. Then I touched /var/log/m.log and chowned it to mysql:root. Finally I set the permissions to 660 (like /var/log/mysqld.log which is working fine). Nothing is appearing in the log and I'm not sure what I'm doing wrong.

    Any help would be greatly appreciated. Thanks.
     
  2. AndyReed

    AndyReed Well-Known Member
    PartnerNOC

    Joined:
    May 29, 2004
    Messages:
    2,222
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    Minneapolis, MN
    Using your favorite Linux editor, view
    /etc/my.cnf
    Under
    Add the following directives:
    Save and then run these commands:

    touch /var/log/mysqld.slow.log
    chown mysql.mysql /var/log/mysqld.*
    /scripts/restartsrv mysql
     
  3. esolutions

    esolutions Member

    Joined:
    Aug 16, 2006
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Okay I added those lines, however I noticed that I don't have any slow queries (according mysqladmin). What I would like to do is log all the queries that are being sent to mysql and check those out. I tried adding
    Code:
    log=/var/log/mysql_query.log
    to /etc/my.cnf but nothing is being logged. The permissions on /var/log/mysql_query.log are mysql:mysql 660.

    Also, when I use /scripts restartsrv to restart mysql, it does not show the configuration lines I have added. I don't know if that is pertinent to the problem, but I thought it was a little odd.

    Thanks.
     
  4. tripper

    tripper Member

    Joined:
    Feb 11, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    N.W. Iowa
    You need to add under the mysqld group:
    Code:
    long_query_time = NUM_OF_SECS
    
    sent the NUM_OF_SECS to the number of seconds to trigger the long query then logged.

    Mickalo
     
Loading...

Share This Page