编程技术

mysql命令行怎么开启慢查询日志_编程技术_编程开发技术教程插图

具体方法:

(推荐教程:mysql教程

查看一下默认慢查询的时间10秒

mysql> show variables like "%long%";         
+-----------------+-----------+
| Variable_name   | Value     |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.00 sec)

设置成3秒,加上global,退出再次进入生效

mysql> set global long_query_time=3;         
Query OK, 0 rows affected (0.00 sec)

查看一下慢查询是不是已经开启

mysql> show variables like "%slow%";         
+---------------------+---------------------------------+
| Variable_name       | Value                           |
+---------------------+---------------------------------+
| log_slow_queries    | OFF                             |
| slow_launch_time    | 2                               |
| slow_query_log      | OFF                             |
| slow_query_log_file | /usr/local/mysql/mysql-slow.log |
+---------------------+---------------------------------+
4 rows in set (0.00 sec)

启用慢查询

mysql> set global slow_query_log='ON';          
Query OK, 0 rows affected (0.28 sec)

查看是否已经开启

mysql> show variables like "%slow%";             
+---------------------+---------------------------------+
| Variable_name       | Value                           |
+---------------------+---------------------------------+
| log_slow_queries    | ON                              |
| slow_launch_time    | 2                               |
| slow_query_log      | ON                              |
| slow_query_log_file | /usr/local/mysql/mysql-slow.log |
+---------------------+---------------------------------+
4 rows in set (0.00 sec)

相关推荐:php培训

mysql命令行怎么开启慢查询日志
—–文章转载自PHP中文网如有侵权请联系admin#tyuanma.cn删除

php如何解决回车换行符的转换问题

云服务器推荐