Mysql5.5 configuration of the slow query trace (RPM, for 5.5)

Source: Internet
Author: User
Tags mysql slow query log

1. What is the use of slow queries? It records all SQL statements that execute more than long_query_time time, helping you find SQL that executes slowly, so we can optimize these SQL. 2. How do I turn on slow queries? First, we check that the MySQL server's slow query status is turned on. Connect to MySQL and then execute the following command: (my turned on so that the red circle display "on", does not turn on the display "OFF") is very simple to open the slow query, the operation is as follows: Locate the configuration file for MySQL My.ini (mysql\mysql Server 5.5), add the configuration statement for the slow query below mysqld (Note: Be sure to join below [mysqld], if it is in [Mysqld_safe] The following configuration statements are not valid. I have made this mistake during the configuration process and experienced the pain!) Log-slow-queries: On behalf of the MySQL slow query log storage directory, this directory file must have write permissions,. Long_query_time: The maximum execution time. (MSYQL will record all SQL statements that have been executed for more than 1 seconds, the test time, the time should not be too small, preferably within 5-10 seconds, of course, according to their own standards); [Python]View PlainCopy
    1. <span style= "color: #333333" > Log-queries-not-using-indexes  </span><span style= "color: #66ff99" > </span><span style=
Configure to restart a MySQL later: Let's see if the Mysql-slow.log file is automatically created under the Mysql\mysql Server 5.5\ directory. This is the slow query configuration OK.                 Note: The different version of the MySQL slow query needs configuration files will be different, I am 5.5, not through the configuration file to open slow query, (this method can be used in various versions basically, do not restart, but also do not need to find the location of the configuration file) using DOS command, into MySQL; Turn on Slow query "set Slow_query_log=on;" Via DOS command. The command opens; (Note: Different versions of global may need to format the output without having to try it) "SELECT @ @global. log_output= ' FILE ' or set @ @global. log_output= ' TABLE ';// Set as library table style Show create TABLE mysql.slow_log;//slow query saved to MySQL data in the Slow_log table "can be set by default to Table,file and table can only use one at a time.                                          If you need to change the value of Log_output using "set global log_output= ' TABLE", you can modify the "set log file storage location" Set slow_query_log_file= "Saved path"; Set slow Query Time "set long_query_time=5;" This is set to 5s (note: Using SET global long_query_time=5 may fail)

Mysql5.5 configuration of the slow query trace (RPM, for 5.5)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.