MySQL wait_timeout Variable - GLOBAL vs SESSION

后端 未结 3 1125
灰色年华
灰色年华 2020-12-07 16:46
SHOW VARIABLES LIKE \"%wait%\"

Result: 28800

SET @@GLOBAL.wait_timeout=300

SHOW GLOBAL VARIABLES LIKE \"%wait%\"

Result: 300

SHOW SESSION VARIABLES LIKE \"%wait         


        
3条回答
  •  执笔经年
    2020-12-07 17:15

    Your session status are set once you start a session, and by default, take the current GLOBAL value.

    If you disconnected after you did SET @@GLOBAL.wait_timeout=300, then subsequently reconnected, you'd see

    SHOW SESSION VARIABLES LIKE "%wait%";
    
    Result: 300
    

    Similarly, at any time, if you did

    mysql> SET session wait_timeout=300;
    

    You'd get

    mysql> SHOW SESSION VARIABLES LIKE 'wait_timeout';
    
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | wait_timeout  | 300   |
    +---------------+-------+
    

提交回复
热议问题