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