我希望MySQL将所有查询视为慢查询并将其记录到表中。
MySQL版本是5.1.69。我做了以下事情:
set global log_output = "TABLE";
set global log_slow_queries = 1;
set global long_query_time = 0;
但是,虽然已执行查询,但表mysql.slow_log
仍为空。为什么? general_log也已启用,mysql.general_log
包含所有查询。
答案 0 :(得分:2)
Did you restart the server after updating the `my.cnf` file?
Please issue:
SELECT @@global.general_log;
SELECT @@global.general_log_file;
SELECT @@global.log_output;
These are the de-facto variables as the server sees them.
You may change tgem dynamically as follows:
SET GLOBAL general_log:=1;
SET GLOBAL log_output := 'FILE';
Also, as last resort, try:
FLUSH LOGS;
to close+reopen log file descriptor.
答案 1 :(得分:1)
动态设置这些全局变量的问题是它不会影响现有会话。
任何现有会话都已设置@@session.long_query_time
,@@global.long_query_time
不会覆盖。
如果在进行全局更改后创建了任何新会话,它们将继承新值,因此在这种情况下,您应该看到新会话的查询,但不会查看旧会话。