Mysql Open Query Log

Source: Internet
Author: User
Tags mysql command line

First of all, the following configuration can be configured for most of the direct dynamic configuration, applicable to not restart the MySQL situation, such as the online server can not easily restart, but after the restart after the combination of failure, there is a direct modification of the configuration file, need to restart MySQL configuration permanently valid.

1. Open General_log:

Performed on the MySQL command line or in the Client management tool: SHOW VARIABLES like "general_log%";

Results:

General_log OFF
General_log_file/var/lib/mysql/localhost.log

Off indicates no logging turned on

Execute open log and log path and log file name separately

SET GLOBAL general_log_file = '/var/lib/mysql/localhost.log ';
SET GLOBAL general_log = ' on ';

Also pay attention to

All SQL executed at this time is not recorded and is easy to view, but if you restart MySQL you will stop recording and you need to reset it.

SHOW VARIABLES like "log_output%";

If it is none, the description does not output, if it is the output to the log file, if the table is output to the MySQL library in the General_log table, this on-demand configuration, set the way:

SET GLOBAL log_output= ' Table,file '

2. Turn on slow query

Slow-query-log=1--Turn on slow query
Slow_query_log_file= "103-54-slow.log"--Slow query log file name, default to the same path as the data directory
Long_query_time=1--more than 1s think is slow query

3. Turn on the unused indexed SQL filtering configuration:

Log_queries_not_using_indexes

Add this line directly to the configuration file, or:

Log_queries_not_using_indexes =1

Restart MySQL.

Article from 73826679

Mysql Open Query Log

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.