Preface Slow query log is a very important function in MySQL. We can enable the slow query log function of MySQL so that we can analyze the execution status and performance of each SQL statement and optimize it accordingly. This article introduces the relevant content about enabling Slow query in MySQL. Let’s take a look at the detailed introduction. Here’s how: 1: Log in to the database to check whether Slow query is 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 the slow query log is disabled. You can enable it by setting the value of slow_query_log: (This is temporarily enabled and will become invalid after restarting the service. If you want to disable it permanently, remember to add a statement in 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 data is written: At this point, the above Mysql slow startup job is completed! -------------------------- Permanently enable 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 long_query_time Queries exceeding this number of seconds are written to the log log_output=file must specify a file or a table. If it is a table, the slow query information will be saved in the slow_log table under the mysql database. This point must be made clear. The default value is NONE Open the my.cnf configuration file and add the following code: log_output=file slow_query_log=on ; slow_query_log_file = /tmp/mysql-slow.log long_query_time = 2 Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: The pitfalls of deploying Angular projects in Nginx
>>: Install Linux rhel7.3 operating system on virtual machine (specific steps)
This article shares with you the installation tut...
1. Single row overflow 1. If a single line overfl...
This article shares the installation tutorial of ...
Whether it is a corporate website, a personal blo...
This article uses examples to illustrate the prin...
The simple installation configuration of mysql5.7...
Table of contents 1. Multiple .catch 2. Multiple ...
1. The significance of persistent statistical inf...
1. Create a user: Order: CREATE USER 'usernam...
What is an HTML file? HTML stands for Hyper Text M...
Preface: Partitioning is a table design pattern. ...
Fabric.js is a very useful canvas operation plug-...
Carousel The main idea is: In the large container...
Slideshows are often seen on web pages. They have...