日期:2014-05-16 浏览次数:20692 次
1.在如下文件:
D:\Program Files\MySQL\MySQL Server 5.0\my.ini
找到如下项:
[mysqld]
然后添加:
log-slow-queries=/data/mysqldata/slowquery.log
long_query_time=2
2.重启服务,查看
mysql> show variables like 'long%';
+-----------------+-------+
| Variable_name?? | Value |
+-----------------+-------+
| long_query_time | 2???? |
+-----------------+-------+
1 row in set (0.00 sec)
mysql> set long_query_time=5;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'long%';
+-----------------+-------+
| Variable_name?? | Value |
+-----------------+-------+
| long_query_time | 5???? |
+-----------------+-------+
1 row in set (0.00 sec)
mysql>
3.说明
在mysql安装目录下的:
/data/mysqldata/slowquery.log
当查询时间超过2秒,生成日志