What is actual difference between wait_timeout and interactive_timeout?


interactive_time is for interactive sessions, whereas wait_timeout is for non-interactive sessions.

What's an interactive session? It's one with a human at the keyboard.

When your code connects to MySQL, runs a query and then spends 3 seconds processing that query before disconnecting, that's 3 seconds of the wait_timeout.

When you use the mysql command line client to connect, run a command and spend 10 seconds reading the output, that's 10 seconds of interactive_timeout. If you walk away and have lunch, that's 3600 seconds of interactive_timeout.

In both cases, when you or your code runs another query, the waiting time is reset back to 0.

You can see the values for all the current sessions by typing show processlist. The values in the sleep(5) function is the number of seconds since that connection last did anything.

  • thank you, this helped me a lot to understand the difference, very well explained. – Fernando Gabrieli Nov 28 '18 at 16:43
  • so let's say I have a query that takes 2 minutes to run, would MySQL disconnect my connections if wait_timeout is less than 2 minutes? – Soheil Rahsaz Dec 14 '20 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.