Home > Database > Mysql Tutorial > How to set up slow query log in MySQL?

How to set up slow query log in MySQL?

黄舟
Release: 2017-08-02 14:11:35
Original
1334 people have browsed it

In the process of checking mysql statements, you need to query the slower sql statements of mysql and output them, and then tune the slower sql statements, which also facilitates logging. From the output, you can view the specific sql statement.

1. Open the mysql console and check whether slow query is turned on.

show variables like'log_slow_queries';
Copy after login
Copy after login

is displayed as OFF

How to set up slow query log in MySQL?

2. Use the mysql that comes with the program to open and run the program.

How to set up slow query log in MySQL?


##3. Then select mysql that is Can.

How to set up slow query log in MySQL?

4. When the next-level menu pops up, select my.ini.

How to set up slow query log in MySQL?


##5. Then at the end of the file In the location,

log-slow-queries="D:/mysql/log/mysql-slow.log"  #慢查询sql日志
long_query_time=5     #多长时间为慢sql   就是为超过5s的就输出日志
Copy after login

How to set up slow query log in MySQL?

6. Then restart the program.


How to set up slow query log in MySQL?


##7. After entering In the mysql console, running

show variables like'log_slow_queries';
Copy after login
Copy after login
again will display on, indicating that the slow query is successfully opened.


The above is the detailed content of How to set up slow query log in MySQL?. 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