你的位置:PHP先生 phpsir.com >> Linux管理 >> 数据库管理 >> 详细内容 在线投稿

mysql slow query 慢查询设置

发布: 2010-6-16 16:03 |  作者: phpsir |   查看: 14次

1:首先配置如下
log_slow_queries       = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes

有如下警告

100510  2:42:59 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.


2:这次把log_slow_queries    换成slow_query_log
slow_query_log          = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes

换成slow_query_log,也有警告
100510  2:45:30 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set


这样就让我疑惑,改了slow_query_log ,log-queries-not-using-indexes为什么会报错呢,难道是log-queries-not-using-indexes与 log_slow_queries 绑定了?
其实不然,后仔细阅读手册

CODE:

Control the slow query log as follows:

Before 5.1.6, the slow query log destination is always a file. To enable the log, start mysqld with the --log-slow-queries[=file_name] option.

As of MySQL 5.1.6, the destination can be a file or a table, or both. Start mysqld with the --log-slow-queries[=file_name] option to enable the slow query log, and optionally use --log-output to specify the log destination (as described in Section 5.2.1, “Selecting General Query and Slow Query Log Output Destinations”).

As of MySQL 5.1.12, as an alternative to --log-slow-queries, use --slow_query_log[={0|1}] to specify the initial slow query log state. In this case, the default slow query log file name is used. With no argument or an argument of 1, --slow_query_log enables the log. With an argument of 0, this option disables the log.

As of MySQL 5.1.29, use --slow_query_log[={0|1}] to enable or disable the slow query log, and optionally --slow_query_log_file=file_name to specify a log file name. The --log-slow-queries option is deprecated.
尤 其是这段:
As of MySQL 5.1.29, use --slow_query_log[={0|1}] to enable or disable the slow query log, and optionally --slow_query_log_file=file_name to specify a log file name. The --log-slow-queries option is deprecated
后把配置改为如下:
slow_query_log=1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes

如果仍然没有找到解决问题的思路,请联系 PHP先生 QQ 733905

TAG: mysql slow 查询 设置
打印 | 收藏此页 |  推荐给好友 | 举报
上一篇 下一篇
 

评分:0

发表评论
seccode 换一个
查看全部回复【已有0位网友发表了看法】