Home > Database > Mysql Tutorial > Mysql database enables slow query log

Mysql database enables slow query log

迷茫
Release: 2017-03-26 11:34:18
Original
1202 people have browsed it

Modify the configuration file

Add the following two sentences to the configuration file my.ini

 log-slow-queries = C:\xampp\mysql_slow_query.log2 long_query_time=3
Copy after login

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 a query that takes more than how many seconds to be a slow query, unit: seconds.

Check the configuration and verify whether the configuration is successful:

//查看慢查询时间,单位:s
show variables like "long_query_time";
Copy after login
//查看慢查询配置情况
show status like "%slow_queries%";
Copy after login
//查看慢查询日志路径
 show variables like "%slow%";
Copy after login

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;
Copy after login

Check the number of slow queries:

show global status like '%slow%';
Copy after login

The above is the detailed content of Mysql database enables slow query log. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template