Check the latest slow log and check whether slow log is enabled.
Mysql> show variables like '% slow % ';
+ --------------------- + ------------------------------------------ +
| Variable_name | Value |
+ --------------------- + ------------------------------------------ +
| Log_slow_queries | OFF |
| Slow_launch_time | 2 |
| Slow_query_log | OFF |
| Slow_query_log_file |/mysqllog/slow_log/slow_queries_3306.log |
+ --------------------- + ------------------------------------------ +
4 rows in set (0.00 sec)
If it is OFF, it is closed. Open it immediately.
Mysql> set global slow_query_log = 'on ';
ERROR 1146 (42S02): Table 'mysql. slow_log 'doesn' t exist
Mysql>
Mysql>
Mysql> set global slow_query_log = 1;
ERROR 1146 (42S02): Table 'mysql. slow_log 'doesn' t exist
Mysql>
Mysql> exit
Bye
An error is reported. check the mysql database for the table:
Mysql> use mysql
Database changed
Mysql> desc slow_log;
ERROR 1146 (42S02): Table 'mysql. slow_log 'doesn' t exist
The mysql. slow_log table is still required and cannot be output to FILE without the slow log table. This table is slow when the log_output parameter is enabled and set to table. logs are recorded in this table, but because the record of this table will affect the performance, it is generally recorded in the FILE and then processed by the script. If an error is reported, create a temporary table. But remember to disable binary writing because it is a dual-master:
Mysql> set session SQL _log_bin = 0;
Query OK, 0 rows affected (0.00 sec)
Mysql> use mysql
Database changed
Mysql> create table 'low _ log '(
-> 'Start _ time' timestamp not null default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-> 'User _ host' mediumtext not null,
-> 'Query _ time' time not null,
-> 'Lock _ time' time not null,
-> 'Rows _ sent' int (11) not null,
-> 'Rows _ examined' int (11) not null,
-> 'Db' varchar (512) not null,
-> 'Last _ insert_id 'int (11) not null,
-> 'Insert _ id' int (11) not null,
-> 'Server _ id' int (10) unsigned not null,
-> 'SQL _ text' mediumtext NOT NULL
->) ENGINE = csv default charset = utf8 COMMENT = 'just only a slow log ';
Query OK, 0 rows affected (0.02 sec)
Mysql>
Mysql>
Then enable slow log
Mysql> set global slow_query_log = 1;
Query OK, 0 rows affected (0.00 sec)
Mysql>
Mysql>
Mysql>
Mysql> select sleep (10), 1 as;
+ ----------- + --- +
| Sleep (10) | a |
+ ----------- + --- +
| 0 | 1 |
+ ----------- + --- +
1 row in set (10.00 sec)
Mysql>
Check whether the slow query SQL is written into the slow log.
Ll slow_queries_3306.log
-Rw ---- 1 mysql 0 Feb 10 slow_queries_3306.log
It turns out to be empty. Why?