How to enable slow log query in MySQL

Source: Internet
Author: User

How to enable slow log query in MySQL

In Windows, find the my. ini file in the MySQL installation directory. The mysql version I use is earlier than 5.1.40.

Add the following lines in my. ini: MySQL Method for enabling slow log query

[Mysqld]

It is slow to define how many seconds the query has exceeded. Here I define 2 seconds

Long_query_time = 2

// 5.0, 5.1, and other versions are configured as follows

Define the Log Path for slow Query

Log-slow-queries = E:/mysqldb/mysqlslowquery. log

// 5.5 and later versions are configured as follows

Slow_query_log = ON

Slow_query_log_file = E:/mysqldb/slow_query_log.txt

The preceding configuration takes effect only when the mysql server process mysqld is restarted. You can also enable slow query logs dynamically.

View long_query_time

When the SQL statement runs beyond the value set by long_query_time, the statement is recorded in the slow query log. The unit of this parameter is seconds.

View slow_query_log Parameters

Set slow query:

Mysql> set global slow_query_log = on;

Mysql> set global long_query_time = 1;

Mysql> select sleep (2 );

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.