SELECT @@host_cache_size;
SHOW GLOBAL VARIABLES LIKE "host_cache_size";
SET GLOBAL host_cache_size=200;
Requires the SYSTEM_VARIABLES_ADMIN privilegeThe cache can be flushed by changing the host_cache_size (see above), truncating the host_cache table, or executing the FLUSH HOSTS command.
TRUNCATE TABLE performance_schema.host_cache;
Requires the DROP privilige for the table.FLUSH HOSTS;
Requires the RELOAD privilegeDeprecated as of MySQL 8.0.23 (8)The number of seconds the server waits for activity on an interactive connection before closing it. (2)
SELECT @@interactive_timeout;
SHOW GLOBAL VARIABLES LIKE "interactive_timeout";
SET GLOBAL interactive_timeout=28800;
SET GLOBAL interactive_timeout=180;
SET GLOBAL interactive_timeout=3600;
# 8 Hours (Default)
# 3 Minutes
# 1 hour
Defines the upper limit for the number of concurrent connections.
SELECT @@max_connections;
SHOW GLOBAL VARIABLES LIKE "max_connections";
SELECT *
  FROM performance_schema.variables_info
 WHERE variable_name = 'max_connections';Â
SHOW STATUS LIKE 'MAX_USED_CONNECTIONS%';
SET GLOBAL max_connections = 150;
Changes setting only until instance restartSET PERSIST max_connections = 150;
Persists setting to mysqld-auto.cnf (which overrides my.cnf at restart)The maximum value is: 4294967295
SELECT @@max_connect_errors;
SHOW GLOBAL VARIABLES LIKE "max_connect_errors";
Specifies how long (in milliseconds) a query can execute for before it is automatically killed.
SELECT @@max_execution_time;
SHOW GLOBAL VARIABLES LIKE "max_execution_time";
SET GLOBAL max_execution_time=0;
SET GLOBAL max_execution_time=1800000;
SET GLOBAL max_execution_time=2700000;
SET GLOBAL max_execution_time=3600000;
# Disable
# 30 minutes
# 45 minutes
# 1 hour
The number of seconds the server waits for activity on a noninteractive connection before closing it. (1)
SELECT @@wait_timeout;
SHOW GLOBAL VARIABLES LIKE "wait_timeout";
SET GLOBAL wait_timeout=28800;
SET GLOBAL wait_timeout=180;
SET GLOBAL wait_timeout=3600;
# 8 Hours (Default)
# 3 Minutes
# 1 hour
"The number of connections that were aborted because the client died without closing the connection properly." (3)
Client not closing the connection properly
"The number of failed attempts to connect to the MySQL server." (4)
These should correlate to entires like this in the mysql.log (if log_warnings parameter is set to 2)...
2023-01-11T03:24:06.161568Z 3067 [Note] Aborted connection 3067 to db: 'mydb' user: 'mysuer' host: 'myhost' (Got timeout reading communication packets)Incorrect password
No matching host for user
Malformed connection strings (e.g. port scanners can trigger this).
Hitting max_connections limit (see earlier on this page).
Killing connections
"The number of connection attempts (successful or not) to the MySQL server." (6)
"The number of errors that occurred during calls to accept() on the listening port." (5)
"The number of connections refused due to internal errors in the server, such as failure to start a new thread or an out-of-memory condition." (5)
"The number of connections refused because the server max_connections limit was reached." (5)
"The number of errors that occurred while searching for connecting client IP addresses." (5)
"The number of errors that occurred during calls to select() or poll() on the listening port. (Failure of this operation does not necessarily means a client connection was rejected.)" (5)
"The number of connections refused by the libwrap library." (5)