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.