Detailed introduction on how to enable slow query log in mysql database

黄舟
Release: 2017-03-18 14:07:43
Original
1400 people have browsed it

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

The first sentence is used to define the path of the slow query log (if it is alinuxsystem, 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";
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 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!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!