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

How to set up slow query log in MySQL?

黄舟
黄舟Original
2017-08-02 14:11:351245browse

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';

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的就输出日志

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';
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!

Statement:
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