如何在 Windows 上监控 MySQL 查询
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3855889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to monitor MySQL queries on Windows
提问by BreakPhreak
Is there any easy way to track/monitor all the SQL of the queries, executed by an MySQL server (on a Windows machine)?
是否有任何简单的方法来跟踪/监视由 MySQL 服务器(在 Windows 机器上)执行的所有 SQL 查询?
Update: I am asking about the free tool.
更新:我问的是免费工具。
采纳答案by BreakPhreak
- Send this command to the server:
set global general_log=1;
- Find the log file (the default on Win7 it resides in
C:\ProgramData\MySQL\MySQL Server 5.1\data
) and has a name just like the computer. - Examine the log :)
- Set the
general_log
back to0
to return the DB server performance back to normal.
- 将此命令发送到服务器:
set global general_log=1;
- 找到日志文件(它驻留在 Win7 上的默认值
C:\ProgramData\MySQL\MySQL Server 5.1\data
)并具有与计算机一样的名称。 - 检查日志:)
- 设置
general_log
back to0
使 DB 服务器性能恢复正常。
回答by serge.k
What worked for me on local windows 7 x64 installation of MYSQL 5.6 was:
在 MYSQL 5.6 的本地 Windows 7 x64 安装上对我有用的是:
Open your my.ini file and make sure you have these lines:
Long query log
long_query_time = 1 slow_query_log = 1 slow_query_log_file = "C:\Zend\MySQL5.6\slowquery.log"
Set General Log
general_log=1 general_log_file = "C:\Zend\MySQL5.6\genquery.log"
Save file and restart the service
打开您的 my.ini 文件并确保您有以下几行:
长查询日志
long_query_time = 1 slow_query_log = 1 slow_query_log_file = "C:\Zend\MySQL5.6\slowquery.log"
设置一般日志
general_log=1 general_log_file = "C:\Zend\MySQL5.6\genquery.log"
保存文件并重启服务
To switch off general query logs, set general_log value to 0 and restart. And do not forget to change the paths of log files to match your system.
要关闭常规查询日志,请将 general_log 值设置为 0 并重新启动。并且不要忘记更改日志文件的路径以匹配您的系统。