日期:2014-05-16  浏览次数:20866 次

Mysql开启慢查询日志
Mysql慢查询日志_1--如何开启慢查询日志
Windows下开启MySQL慢查询
MySQL在Windows系统中的配置文件一般是是my.ini找到[mysqld]下面加上
log-slow-queries=C:/Program Files/MySQL/MySQL Server 5.1/Datafiles/slowquery.log
long_query_time=2
log-slow-admin-statements
log-queries-not-using-indexes
Linux下启用MySQL慢查询
MySQL在Windows系统中的配置文件一般是是my.cnf找到[mysqld]下面加上
log-slow-queries=/usr/loca/mysql/Datafiles/slowquery.log
long_query_time=2
log-slow-admin-statements
log-queries-not-using-indexes
注意
log-slow-queries =C:/Program Files/MySQL/MySQL Server 5.1/Datafiles/slowquery.log为慢查询日志存放的位置,一般这个目录要有MySQL的运行帐号的可写权限,一般都将这个目录设置为MySQL的数据存放目录;
long_query_time=2中的2表示查询超过两秒才记录;
log-queries-not-using-indexes也是5.1的新选项,可以没有使用index的sql语句记录到慢查询日志中
log-slow-admin-statements该命令选项可以将OPTIMIZE TABLE, ANALYZE TABLE, 以及ALTER TABLE 等管理操作写道慢查询日志中.