How can I enable MySQL#39;s slow query log without restarting MySQL?(如何在不重新启动 MySQL 的情况下启用 MySQL 的慢查询日志?)
问题描述
我按照这里的说明操作:http://crazytoon.com/2007/07/23/mysql-changed-runtime-variables-with-out-restarting-mysql-server/ 但这似乎只是设置了阈值.>
我还需要做其他事情吗,比如设置文件路径?
根据 MySQL 的文档
<前>如果没有为 --log-slow-queries 提供 file_name 值,则默认名称为主机名-slow.log.服务器在数据目录中创建文件,除非给出绝对路径名以指定不同的目录.运行
显示变量
不指示任何日志文件路径,并且我在我的服务器上没有看到任何慢查询日志文件...
编辑
看起来我使用的是服务器版本 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 docs
If no file_name value is given for --log-slow-queries, the default name is host_name-slow.log. The server creates the file in the data directory unless an absolute path name is given to specify a different directory.
Running
SHOW VARIABLES
doesn't indicate any log file path and I don't see any slow query log file on my server...
EDIT
Looks 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 variable
I 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 的慢查询日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在不重新启动 MySQL 的情况下启用 MySQL 的慢查询日志?
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在多列上分布任意行 2021-01-01
- oracle区分大小写的原因? 2021-01-01
