赞
踩
mysql> show variables like '%slow%';
+---------------------------+-------------------------+
| Variable_name | Value |
+---------------------------+-------------------------+
| slow_query_log | ON #OFF关闭,ON开启 |
| slow_query_log_file | /var/log/mysql-slow.log |
+---------------------------+-------------------------+
mysql> show variables like '%long_query_time%';
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| long_query_time | 5.000000 |
+-----------------+----------+
#开启慢查询
mysql> set global slow_query_log='ON';
#设置慢查询日志存放的位置
mysql> set global slow_query_log_file='/usr/local/mysql/data/mysql-slow.log';
#超过2秒就记录
mysql> set global long_query_time=2;
修改my.cnf
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
slow_query_log = ON
slow_query_log_file = /usr/local/mysql/data/mysql-slow.log
long_query_time = 2
[root@localhost ~]# service mysqld restart #重启生效
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。