Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Jan 2007
    Location
    India
    Posts
    10

    To enable slow query logging of mysql

    Enter the following lines in /etc/my.cnf and restart mysql

    # enable slow query log
    #This is a great tool for checking what queries take too long
    log-slow-queries=/tmp/slow_queries.log
    log-update = /var/lib/mysql/updates.log
    ----
    SparkSupport
    Redefining Support Integrating Ideas
    http://sparksupport.com
    Articles

  2. #2
    Senior Member
    Join Date
    May 2009
    Posts
    179
    MySQL has built-in functionality that allows you to log SQL queries to a file , You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable , The slow query log is used to find queries that take a long time to execute and are therefore candidates for optimization.

    To enable you just need to add some lines to your my.cnf file, and restart. Add the following:

    To enable slow Query Log only
    log-slow-queries = /var/log/mysql/mysql-slow.log
    long_query_time = 1

    After enabling slow query, mysqld writes a statement to the slow query log file and it consists of all SQL statements that took more than long_query_time seconds to execute. The time to acquire the initial table locks is not counted as execution time. mysqld only log after SQL statements has been executed and after all locks have been released, so log order might be different from execution order. The minimum and default values of long_query_time are 1 and 10, respectively.

    To enable full Log Query
    log=/var/log/mysqldquery.log

    The above will log all queries to the log file.

    enjoy...........

  3. #3
    Junior Member
    Join Date
    Apr 2017
    Location
    London
    Posts
    5
    How we use CHECK constraint in SQL?

  4. #4
    Junior Member
    Join Date
    Sep 2017
    Location
    India
    Posts
    3
    Syntax for /etc/my.cnf in Red Hat 9:

    [mysqld]
    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

  5. #5
    Senior Member
    Join Date
    Feb 2022
    Posts
    148
    Enable the Slow Query Log
    Log in to your server as the root user via SSH.
    Open the my.cnf file with a text editor and add the following block of code under the mysqld section: ...
    Create the /var/log/mysql-slow.log file and set its user as the mysql user. ...
    Restart MySQL or MariaDB. ...
    Start monitoring the slow query logfile.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

  Find Web Hosting      
  Shared Web Hosting UNIX & Linux Web Hosting Windows Web Hosting Adult Web Hosting
  ASP ASP.NET Web Hosting Reseller Web Hosting VPS Web Hosting Managed Web Hosting
  Cloud Web Hosting Dedicated Server E-commerce Web Hosting Cheap Web Hosting


Premium Partners:


Visit forums.thewebhostbiz.com: to discuss the web hosting business, buy and sell websites and domain names, and discuss current web hosting tools and software.