Adjust the time the server or client waits before dropping an idle or stalled MariaDB connection.
Timeout variables decide how long MariaDB waits for a client to authenticate (connect_timeout) or remain idle (wait_timeout, interactive_timeout) before closing the connection to free resources.
Run SHOW VARIABLES LIKE 'wait\_timeout';
or query INFORMATION_SCHEMA.GLOBAL_VARIABLES
. This instantly shows whether defaults—28800 seconds for wait_timeout and 10 seconds for connect_timeout—are still active.
Set it once per connection: SET SESSION wait_timeout = 60;
. The new value applies only to your session and lasts until disconnect.
With SUPER or SYSTEM_VARIABLES_ADMIN, execute SET GLOBAL wait_timeout = 120;
. Changes take effect immediately for new sessions but vanish after a restart unless placed in my.cnf
.
Add lines under [mysqld]
:wait_timeout = 120
. Restart the server to apply.
connect_timeout = 15
CLI users pass --connect-timeout=15
:mysql --connect-timeout=15 -u app_user -p ecommerce
. Libraries expose the same option through connection strings or driver parameters.
Busy APIs often set wait_timeout to 60-300 s to stop connection leakage. Long-running BI tools may raise interactive_timeout to 3600 s. Test under load before finalizing.
After altering a variable, run SHOW SESSION VARIABLES LIKE 'wait\_timeout';
or reconnect and inspect again to confirm the server accepted the new setting.
Yes, if your application uses a pool and reconnect logic. Values under 30 s can starve long-running statements, so monitor errors before deploying.
No. connect_timeout only affects new handshakes. Existing sessions remain unaffected.
No. Any authenticated user can run SET SESSION wait_timeout, but GLOBAL changes need higher privileges.