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 mysql to view slow query logs

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

Share

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

This article mainly explains "how to open mysql to view slow query log". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to open mysql to view slow query logs".

Environment: percona5.6.27

Check whether the function of viewing slow query logs has been enabled in the database

Mysql > show variables like'% slow%'

+-+

| | Variable_name | Value |

+-+

| | log_slow_admin_statements | OFF |

| | log_slow_filter |

| | log_slow_rate_limit | 1 | |

| | log_slow_rate_type | session |

| | log_slow_slave_statements | OFF |

| | log_slow_sp_statements | ON |

| | log_slow_verbosity |

| | max_slowlog_files | 0 | |

| | max_slowlog_size | 0 | |

| | slow_launch_time | 2 | |

| | slow_query_log | OFF |

| | slow_query_log_always_write_time | 10.000000 | |

| | slow_query_log_file | / disk/DB/mysql/trcloud-wujian-test01-slow.log |

| | slow_query_log_timestamp_always | OFF |

| | slow_query_log_timestamp_precision | second |

| | slow_query_log_use_global_control |

+-+

16 rows in set (0.01 sec)

Parameter slow_query_log indicates whether to enable slow query log.

The slow_launch_time parameter indicates how many seconds the query will be recorded in the slow log.

The slow_query_log_file parameter indicates a slow log file

Now modify the my.cnf file to set the following content

Slow-query-log=1

Slow-launch-time=30

Restart the database service mysql restart.

Of course, you can also use set global slow-query-log=1 to modify the parameters.

At this point, I believe you have a deeper understanding of "how to open mysql to view slow query logs". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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