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 to enable Slow slow query in MySQL

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces how to open Slow slow query in MySQL, the content is very detailed, interested friends can refer to, hope to be helpful to you.

The methods are as follows:

1: log in to the database to see if Slow slow query has been enabled:

Mysql > show variables like 'slow_query%'

2: enable Mysql slow log:

By default, the value of slow_query_log is OFF, which means that slow log is disabled, which can be enabled by setting the value of slow_query_log: (here, it will expire after restarting the service. If you want to fail permanently, please add a statement to the myqsl configuration file, see the end of the article.)

Mysql > set global slow_query_log=1;Query OK, 0 rows affected (0.03 sec)

3: check whether it is enabled:

Mysql > show variables like 'slow_query%'

4: write mysql slow statement to test whether slow data is written:

Mysql > select sleep (10) as a, 1 as b

5: check the Mysql Slow file to see if the data is written:

So far, complete the above Mysql slow start-up operations!

-

Permanently open the Mysql Slow log:

Slow_query_log_file slow query log file path

Slow_query_log is used to specify whether to open the slow query log.

Queries over how many seconds of long_query_time are written to the log.

Log_output=file must specify either file or table. If it is table, the slow query information is saved to the slow_ log table under the mysql library. Be clear about this. The default value is NONE

Open the my.cnf configuration file and add the following code:

Log_output=fileslow_query_log=on; slow_query_log_file = / tmp/mysql-slow.loglong_query_time = 2 so much about how to enable Slow slow query in MySQL. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

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