Mysql database enables slow query logs and mysql database logs

Source: Internet
Author: User

Mysql database enables slow query logs and mysql database logs

Modify configuration file

Add the following two sentences to the configuration file my. ini:

1 log-slow-queries = C: \ xampp \ mysql_slow_query.log2 long_query_time = 3


The first statement is used to define the path for slow query logs (for linux systems, permission issues are involved)
The second clause is used to define the number of seconds that have elapsed since the query time is slow. Unit: seconds.

 

Check whether configuration verification is successful:

// View the slow query time. Unit: sshow variables like "long_query_time ";
// View the slow query configuration. show status like "% slow_queries % ";
// View the slow query Log Path show variables like "% slow % ";

 

Perform the slow query operation to verify whether logs are recorded:

The self-built environment has a small amount of data and it is difficult to simulate slow queries. You can simulate the following statement instead:
Select sleep (10), name from user where userid = 1;

 

View the number of slow queries:

Show global status like '% slow % ';

 

Related Article

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.