How to start MySQL slow Query

Source: Internet
Author: User
Tags mysql slow query log

1. How to enable slow query for MySQL in Windows:

The configuration file of MySQL in Windows is usually my. ini, and the path of my path is c: \ mysql \ My. ini. You can find

Compile my. ini and add it under [mysqld]

Log-Slow-queries
= D: \ mysql \ logs \ slow. Log: Slow query of log storage location
Long_query_time = 2 indicates that the query takes more than two seconds to record
Log-queries-not-using-indexes indicates that no index is used in the query records.

It is recommended that you restart MySQL after adding it.
Net stop MySQL
Net start MySQL slow query log storage location
Long_query_time = 2 indicates that the query takes more than two seconds to record
Log-queries-not-using-indexes indicates that no index is used in the query records.

It is recommended that you restart MySQL after adding it.
Net stop MySQL
Net start MySQL

Or restart MySQL in the system service.


D: \ mysql \ logs \ slow. log must be manually created. Otherwise, log records cannot be obtained.



----------------------------------------------------------------------------------

The following is a conversion, because I do not have a Linux system. I checked it online and hope it will be useful to you.

2. How to enable slow query in MySQL in Linux:
The configuration file of MySQL in Linux is usually my. CNF, and my path is/etc/My. CNF. You can find
VI/etc/My. CNF
The same is added under [mysqld]
Log-Slow-queries =/var/lib/MySQL/slowquery. Log
Long_query_time = 2
Log-queries-not-using-Indexes

I will not explain it here. After MySQL is restarted, you can go to/var/lib/MySQL to check whether slowquery. log is generated.
CD/var/lib/MySQL/

All right, the rest is to check.

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.