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