4

I have a my.cnf file. In it I see wait_timeout as well as connect_timeout. What's the difference between these 2?

8

Right from the MySQL Documentation

  • wait_timeout : The number of seconds the server waits for activity on a noninteractive connection before closing it.
  • connect_timeout : The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake

EXAMPLES

  • If wait_timeout is 1800 (30 Minutes), the DB Connection will close in 30 minutes if the connection is idle (indicated by Sleep in the command column of the processlist).
  • If connect_timeout is 10, then mysqld will reject you if you cannot login (authenticate) in 10 seconds.
  • There are separate "interactive" and "batch" versions of wait_timeout. Interactive defaults to 8 hours (IIRC); it shows up (at least) when you use the mysql commandline tool. – Rick James Jan 28 '17 at 16:59
  • concerning wait_timeout whats the best way to see how many db connections are idle eg the default seems to be 8 hours so that must there's a lot of connections just hanging around awaiting timeout – Chris Moutray Sep 2 at 16:37
0

wait_timeout is how long to keep a connection open. connect_timeout is how long to wait for a connection to be made.

This is my best understanding, please comment or edit as needed.

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.