【问题标题】:How to log mysql slow queries for specific database如何记录特定数据库的mysql慢查询
【发布时间】:2012-06-05 03:26:02
【问题描述】:

我的 sql 实例有几个不同的数据库。

我已将 my.cnf 配置为使用以下行记录慢速查询:

log_error=/var/log/mysql/error.log
log_queries_not_using_indexes=1
slow_query_log=1
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=1

它工作正常,但我希望只为特定数据库提供日志。

有可能吗?

【问题讨论】:

    标签: mysql performance configuration centos


    【解决方案1】:

    【讨论】:

    • long_query_time 太不幸了。即使您可以在没有 GLOBAL 的情况下设置它。 (或者也许我错过了一些东西。)
    • 是否可以通过其他方式记录特定数据库的慢查询?
    【解决方案2】:

    你可以在文件中使用mysql慢日志然后使用这个命令来查找特定数据库的慢日志行:

    cat  /var/lib/mysql/slow.log |grep -A 3 {your_db_name}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-06
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多