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

前端 未结 8 974
情歌与酒
情歌与酒 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: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.

提交回复
热议问题