How can I enable MySQL's slow query log without restarting MySQL?

前端 未结 8 904
情歌与酒
情歌与酒 2020-11-28 19:44

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

相关标签:
8条回答
  • 2020-11-28 20:14

    Find log enabled or not?

    SHOW VARIABLES LIKE '%log%';
    

    Set the logs:-

    SET GLOBAL general_log = 'ON'; 
    
    SET GLOBAL slow_query_log = 'ON'; 
    
    0 讨论(0)
  • 2020-11-28 20:21

    These work

    SET GLOBAL LOG_SLOW_TIME = 1;
    SET GLOBAL LOG_QUERIES_NOT_USING_INDEXES = ON;
    

    Broken on my setup 5.1.42

    SET GLOBAL LOG_SLOW_QUERIES = ON;
    SET GLOBAL SLOW_QUERY_LOG = ON;
    set @@global.log_slow_queries=1;
    

    http://bugs.mysql.com/bug.php?id=32565

    Looks like the best way to do this is set log_slow_time very high thus "turning off" the slow query log. Lower log_slow_time to enable it. Use the same trick (set to OFF) for log_queries_not_using_indexes.

    0 讨论(0)
提交回复
热议问题