我还需要做其他事情,例如设置文件路径吗?根据MySQL的文档If no file_name value is given for --log-slow-queries, the default name ishost_name-slow.log. The server creates the file in the data directory unlessan absolute path name is given to specify a different directory.运行SHOW VARIABLES没有指示任何日志文件路径,并且我在服务器上看不到任何慢查询日志文件... 编辑看起来我正在使用服务器版本5.0.77,所以我需要这样做:SET GLOBAL log_slow_queries = 1;但是我得到:错误1238(HY000):变量'log_slow_queries'是只读变量我假设我将需要重新启动服务器并在配置中设置log_slow_queries吗?解决方案尝试SET GLOBAL slow_query_log = 'ON';甚至FLUSH LOGS;这假设您使用的是MySQL 5.1或更高版本.如果使用的是较早版本,则需要重新启动服务器. MySQL手册中对此进行了说明.您可以在配置文件或命令行中配置日志.I followed the instructions here: http://crazytoon.com/2007/07/23/mysql-changing-runtime-variables-with-out-restarting-mysql-server/ but that seems to only set the threshold.Do I need to do anything else like set the filepath?According to MySQL's docsIf no file_name value is given for --log-slow-queries, the default name ishost_name-slow.log. The server creates the file in the data directory unlessan absolute path name is given to specify a different directory.RunningSHOW VARIABLESdoesn't indicate any log file path and I don't see any slow query log file on my server...EDITLooks like I'm using server version 5.0.77, so I needed to do:SET GLOBAL log_slow_queries = 1;but I get: ERROR 1238 (HY000): Variable 'log_slow_queries' is a read only variableI assume I'm going to need to restart the server and have log_slow_queries set in my config? 解决方案 Try SET GLOBAL slow_query_log = 'ON'; and perhaps FLUSH LOGS;This assumes you are using MySQL 5.1 or later. If you are using an earlier version, you'll need to restart the server. This is documented in the MySQL Manual. You can configure the log either in the config file or on the command line. 这篇关于如何在不重新启动MySQL的情况下启用MySQL的慢查询日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 06:14
查看更多