Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does mysql enable slow log?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

First of all, we need to understand four parameters:

Whether to enable slow log in slow_query_log #. Default is OFF. If enabled, set to ON. Slow_query_log_file # slow query log file storage location. Whether log_queries_not_using_indexes # logs SQL that is not used in the index. Default is OFF. If enabled, it is set to ON. How many seconds does the long_query_time # query take before it is recorded in the log? note that the unit is seconds.

Then execute the statement setting (this method will fail when MySQL is restarted)

Once we know the meaning of the parameters, we can set the parameters we need directly. I am using the global settings here.

SET GLOBAL slow_query_log = 'ON';SET GLOBAL slow_query_log_file =' file path (absolute path); SET GLOBAL log_queries_not_using_indexes = 'ON';SET GLOBAL long_query_time = 1; # it should be noted here that the long_query_time parameter will not take effect until the next session, and the current session query is still the original value.

Finally modify the configuration file (permanent settings)

If you want to restart MySQL without invalidation, you can modify the MySQL configuration file. Add the following statement to the configuration file:

Slow_query_log= "ON" slow_query_log_file= "file path (absolute path)" log_queries_not_using_indexes= "ON" long_query_time=1

It will take effect after reboot.

These are the details of how to open the mysql slow query log. Please pay attention to other related articles for more information.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report