0

Is there a way to configure the timeout for inactive clients with mysql?

Example: A MySQL DB has a limit of 100 client connections but some clients are not using the connection any more. I assume MySQL will eventually drop the connection but is this configurable?

1

There are a number of ...timeout... parameters that can be configured for a MySQL instance. Here are a few selected parameters (Ver. 8.x) for your convenience:

Reference: 5.1.7 Server System Variables (MySQL | Documentation)

interactive_timeout

The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option to mysql_real_connect(). See also wait_timeout.

wait_timeout

The number of seconds the server waits for activity on a noninteractive connection before closing it.

On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.

Answering Your Question

Is there a way to configure the timeout for inactive clients with mysql?

It depends. Globally you can define a timeout with the wait_timeout parameter of your MySQL instance. If you are using the specific option CLIENT_INTERACTIVE of the mysql_real_connect() function, then you can use the interactive_timeout parameter.

  • Once you have decreased the timeout, I suggest you also decrease max_connections and max_user_connections. – Rick James Oct 8 '18 at 0: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.