At work, you need to look at MySQL's top 20 slow SQL, optimized one by one, plus the necessary indexes.
But found that the slow query log is not turned on:
Mysql> Show variables like "%query%";
+------------------------------+--------------------------+
| variable_name | Value |
+------------------------------+--------------------------+
| binlog_rows_query_log_events | OFF |
| Ft_query_expansion_limit | 20 |
| Have_query_cache | YES |
| Long_query_time | 3.000000 |
| Query_alloc_block_size | 8192 |
| Query_cache_limit | 4194304 |
| Query_cache_min_res_unit | 4096 |
| Query_cache_size | 268435456 |
| Query_cache_type | OFF |
| Query_cache_wlock_invalidate | OFF |
| Query_prealloc_size | 8192 |
| Slow_query_log | OFF |
| Slow_query_log_file | /data/log/mysql/slow.log |
+------------------------------+--------------------------+
Rows in Set (0.00 sec)
Temporarily use commands
mysql> set global slow_query_log=on; turn on the slow query log with the following error:
ERROR (HY000): File '/data/log/mysql/slow.log ' not found (Errcode:13-permission denied
Workaround:
# Cd/data/log/mysql
# Touch Slow.log
#chmod 777-r Slow.log
Successfully resolved:
mysql> set global slow_query_log=on;
Query OK, 0 rows Affected (0.00 sec)
This article from "to Guanshuxian" blog, declined reprint!
MySQL 5.7 resolves set global slow_query_log=on; error