// mysql · connections

max_connect_errors

Failed connection attempts from one host before it is blocked.

預設
100
Range
1 to 2^64-1
Restart needed
否
Default checked on
MySQL 8.4 LTS

其作用

Counts interrupted handshakes, not wrong passwords. Once blocked, the host gets 'Host is blocked because of many connection errors' until the host cache is flushed.

預設值

100. 100 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'max_connect_errors';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'max_connect_errors';

Change it

SET GLOBAL max_connect_errors = 10000;    -- until the next restart
SET PERSIST max_connect_errors = 10000;   -- now and after restarts

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When to change it

Raise it when load balancer health checks (TCP connects that never authenticate) keep blocking app servers.

What can go wrong

Unblock a host with TRUNCATE TABLE performance_schema.host_cache; FLUSH HOSTS is deprecated.

Questions about max_connect_errors

What is the default value of max_connect_errors in MySQL?

100. 100 (MySQL 8.4).

Does changing max_connect_errors require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When should I change max_connect_errors?

Raise it when load balancer health checks (TCP connects that never authenticate) keep blocking app servers.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check max_connect_errors on your own server

SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.