0

I'm running Windows, IIS, MySQL, PHP.

In my.ini under [mysqld] the value for wait_timeout is set to 60.

wait_timeout = 60

But when I execute the following:

show variables like 'wait_timeout';

It shows me that the value is 28800, which I know is the default.

So I tried to set the value by executing the following:

SET GLOBAL wait_timeout = 60;

But this doesn't seem to work. MySql Workbench tells me "0 rows(s) affected" and when I execute show variables like 'wait_timeout' it still tells me that the value is 28800.

I've also checked interactive_timeout and the story is the same. The value is 28800 and I can't change it.

What am I missing here?

Vincent
  • 736
  • 1
  • 7
  • 11
  • Please check topic: https://stackoverflow.com/questions/22425463/set-global-variables-not-working-mysql – MohammadReza moeini Aug 27 '21 at 15:40
  • When you want to know value of wait_timeout there are two distinct values. SHOW GLOBAL VARIABLES LIKE 'wait_timeout'; and SHOW SESSION VARIABLES LIKE 'wait_timeout'. SHOW VARIABLES LIKE 'wait_timeout' assumes you are wanting the session variable. wait_timeout controls inactivity timeout for usual processing, interactive_timeout controls idle time tolerance (seconds) when using MySQL Command Prompt for processing. When you want to SET SESSION wait_timeout; you need to immediately follow with the request you want to run because a new MySQL command prompt is another session. – Wilson Hauck Aug 29 '21 at 13:57
  • 1
    Vince, Great to see you again on SF. – Wilson Hauck Aug 29 '21 at 14:04

2 Answers2

0

The answer is to set the value without the GLOBAL keyword.

SET wait_timeout = 60;
Vincent
  • 736
  • 1
  • 7
  • 11
0

GLOBAL setting are copied into your SESSION settings when you connect. Use either of these syntaxes:

SET @@... = ...;
SET SESSION ... = ...;

wait_timeout refers to how soon before you will be disconnected. Is that what you want?

Furthermore, there is some confusion over "batch" versus "interactive" timeout. Good look.

Rick James
  • 2,058
  • 5
  • 11
  • I was unable to get it to work with the "@@" but using the SESSION keyword was key! Thank you. – Vincent Aug 31 '21 at 22:17
  • @Vincent - I do make mistakes. Fixed. – Rick James Oct 28 '21 at 16:33
  • Sorry I changed my accepted answer. I was just reviewing this and realized that although your answer set me on the right path it was not the ultimate solution so I thought for future visitors it would be more helpful to highlight the correct solution with a green check mark. – Vincent Oct 29 '21 at 17:18