MySQL-View Slow SQL

Source: Internet
Author: User

"Reprint Address: http://www.cnblogs.com/xzpp/archive/2012/07/18/2598136.html"

See if MySQL is enabled to view slow SQL log files

(1) To see if slow SQL logging is enabled

Mysql> Show variables like ' log_slow_queries ';
+------------------+-------+
| variable_name | Value |
+------------------+-------+
| log_slow_queries | On |
+------------------+-------+
1 row in Set (0.00 sec)

(2) View SQL that executes slower than how many seconds is logged to the log file
Mysql> Show variables like ' long_query_time ';
+-----------------+-------+
| variable_name | Value |
+-----------------+-------+
| Long_query_time | 1 |
+-----------------+-------+
1 row in Set (0.00 sec)

Value=1 here, for 1 seconds.

2. Configure the My.ini file (inux under File name my.cnf), find the [mysqld] section, increase the configuration of the log, as in the following example:
[Mysqld]
Log= "C:/temp/mysql.log"
Log_slow_queries= "C:/temp/mysql_slow.log"
Long_query_time=1

Log indicates the directory where logs are stored;
Log_slow_queries indicates the log directory of SQL logs with long execution time;
Long_query_time indicates how long the execution time is, Unit S.

These configuration items should already exist under Linux, just commented out, and you can remove the annotations. But adding configuration items directly is OK.

MySQL-View Slow SQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.