MySQL turn on slow query log

Source: Internet
Author: User

SQL and Index optimization

database table Structure Optimization

System Configuration

Hardware

mysql> show variables like 'slow_query_log';+----------------+-------+| Variable_name  | Value |+----------------+-------+| slow_query_log | OFF   |+----------------+-------+1 row in set (0.00 sec)

Slow log query does not open, you can open a bit.

Find MY.CNF and add the following:sudo vim /usr/local/mysql/my.cnf

# 添加慢查询日志log_output=fileslow_query_log=on slow_query_log_file = /tmp/mysql-slow.loglong_query_time = 2

Restart MySQL.

mysql> show variables like 'slow_query_log';+----------------+-------+| Variable_name  | Value |+----------------+-------+| slow_query_log | ON    |+----------------+-------+1 row in set (0.00 sec)

At this time, the slow query log has been turned on.

$ sudo cat /tmp/mysql-slow.log /usr/local/mysql/bin/mysqld, Version: 5.6.40-log (Source distribution). started with:Tcp port: 3306  Unix socket: /tmp/mysql.sockTime                 Id Command    Argument

MySQL turn on slow query log

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.