博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL slow query log
阅读量:6880 次
发布时间:2019-06-26

本文共 1571 字,大约阅读时间需要 5 分钟。

The MySQL slow query log enables you to log all queries that take longer than a specified number of seconds to execute.  This should help identify any queries that are not performing sufficiently.

All that is required is two additional lines in the MySQL configuration file “my.cnf” in the [mysqld] section.

[mysqld]
log-slow-queries = /var/log/mysql-slow.log
long_query_time = 4
 

The above configuration will log any queries taking longer than 4 seconds to execute in to the specified log file.

MySQL appears to require that the specified log file exists otherwise the logging is disabled and the error below

appears in the MySQL log. (Or it may be that it didn’t have permissions to create the file. I haven’t investigated).

081013 14:55:37 [ERROR] Could not use /var/log/mysql-slow.log for logging (error 13). Turning logging off for
the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server
and restart it.

To create the log file I did the following:

touch /var/log/mysql-slow.log
chown mysql.mysql /var/log/mysql-slow.log
chmod o-r /var/log/mysql-slow.log

The third command is probably unnecessary, but it meant that the permissions matched the mysqld.log

in the same directory.

Once this is done MySQL needs to be restarted to start the query logging:

service mysql restart
 

This entry was posted on Monday, October 13th, 2008 at 5:34 pm and is filed under . You can follow any responses to this entry through the  feed. You can , or  from your own site.

 

本文转自holy2009 51CTO博客,原文链接:http://blog.51cto.com/holy2010/362340

转载地址:http://nogfl.baihongyu.com/

你可能感兴趣的文章
http数据协商
查看>>
Python骚操作 | 还原已撤回的微信消息
查看>>
Code Coverage API plugin 一个新的代码覆盖率插件
查看>>
DTCC 2019 | 深度解码阿里数据库实现 数据库内核——基于HLC的分布式事务实现深度剖析...
查看>>
【思维导图】NoSQL分布式模型
查看>>
Angular4的依赖注入
查看>>
暴走周刊 5.27
查看>>
年轻人,劝你不要做前端
查看>>
linux 下 android studio 不能输入中文记录
查看>>
如果人工智能“圈养”了人类会怎么样?
查看>>
小程序如何生成海报分享朋友圈
查看>>
检测后台错误
查看>>
微信小程序自定义组件
查看>>
Android Studio 和 Gradle 优化配置总结
查看>>
java8 stream实现列表去重,java8的stream 和lambda的使用实例
查看>>
iOS中通知的添加和移除
查看>>
企业分布式微服务云SpringCloud SpringBoot mybatis (一)服务的注册与发现(Eureka)...
查看>>
批量下载图片
查看>>
Java内存模型(Memory Model)
查看>>
某大型网站迁移纪实(一)
查看>>