This article mainly introduces the detailed explanationmysql databaseHow to open the slowQuerylog related information, friends in need can refer to the following
Database opening Slow query log
ModifyConfiguration file
Add the following two sentences to the configuration file my.ini
log-slow-queries = C:\xampp\mysql_slow_query.log long_query_time=3
The first sentence is used to define the path of the slow query log (if it is a linux system, permission issues will be involved)
The second sentence is used to define how many seconds it takes to exceed The query is a slow query, unit: seconds.
Check the configuration and verify whether the configuration is successful:
//查看慢查询时间,单位:s show variables like "long_query_time";
//查看慢查询配置情况 show status like "%slow_queries%";
//查看慢查询日志路径 show variables like "%slow%";
Perform the slow query operation and verify whether the log is recorded:
Build it yourself The amount of data in the environment is small, and it is difficult to simulate the execution of slow queries. You can simulate it with the following statement:
SELECT SLEEP(10),name from user where userid=1;
Check the number of slow queries:
show global status like '%slow%';
The above is the detailed content of Detailed introduction on how to enable slow query log in mysql database. For more information, please follow other related articles on the PHP Chinese website!