In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to safely empty the online slow query log slow log in mysql. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
1, see the slow log status
Mysql > show variables like'% slow%'
+-- +
| | Variable_name | Value |
+-- +
| | log_slow_queries | ON |
| | slow_launch_time | 2 | |
| | slow_query_log | ON |
| | slow_query_log_file | / mysqllog/slow_log/slow_queries_3306.log |
+-- +
4 rows in set (0.00 sec)
2, stop the slow log server.
Mysql > set global slow_query_log=0
Query OK, 0 rows affected (0.27 sec)
Mysql > show variables like'% slow%'
+-- +
| | Variable_name | Value |
+-- +
| | log_slow_queries | OFF |
| | slow_launch_time | 2 | |
| | slow_query_log | OFF |
| | slow_query_log_file | / mysqllog/slow_log/slow_queries_3306.log |
+-- +
4 rows in set (0.00 sec)
Mysql >
Mysql > show variables like'% slow%';-- check slow log status
+-- +
| | Variable_name | Value |
+-- +
| | log_slow_queries | OFF |
| | slow_launch_time | 2 | |
| | slow_query_log | OFF |
| | slow_query_log_file | / mysqllog/slow_log/slow_queries_3306.log |
+-- +
4 rows in set (0.00 sec)
3, reset the new path of slow log
Mysql > set global slow_query_log_file='/mysqllog/slow_log/slow_queries_3306_new.log'
Query OK, 0 rows affected (0.03 sec)
4, start the slow log server
Mysql >
Mysql >
Mysql > set global slow_query_log=1
Query OK, 0 rows affected (0.01 sec)
Mysql > show variables like'% slow%'
+-+ +
| | Variable_name | Value |
+-+ +
| | log_slow_queries | ON |
| | slow_launch_time | 2 | |
| | slow_query_log | ON |
| | slow_query_log_file | / mysqllog/slow_log/slow_queries_3306_new.log |
+-+ +
4 rows in set (0.00 sec)
5, check the slow sql in the new slow log file.
Mysql > select sleep (10) as a, 1 as b
+-+-
| | a | b | |
+-+-
| | 0 | 1 |
+-+-
1 row in set (10.00 sec)
Mysql >
[mysql@xxx-xxx ~] $more / mysqllog/slow_log/slow_queries_3306_new.log
.
Time Id Command Argument
# Time: 140213 6:44:24
# User@Host: root [root] @ localhost []
# Query_time: 10.000365 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
SET timestamp=1392273864
Select sleep (10) as a, 1 as b
6, backup the old big slow log file to other directory.
Mv / mysqllog/slow_log/slow_queries_3306.log / mysqlbackup/slow_log/slow_queries_3306.log.bak.20140213
This is the end of the article on "how to correctly and safely empty the online slow query log slow log in mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.