// mysql · connections

max_connections

Maximum simultaneous client connections.

デフォルト
151
Range
1 to 100000
Restart needed
いいえ
Default checked on
MySQL 8.4 LTS

何ができるか

One more connection is always allowed for accounts with CONNECTION_ADMIN (or SUPER) so an administrator can get in. Each connection costs a thread and its buffers.

デフォルト値

151. 151 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'max_connections';

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

Change it

SET GLOBAL max_connections = 500;    -- until the next restart
SET PERSIST max_connections = 500;   -- 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

When clients get 'Too many connections' and Max_used_connections reaches the limit. Check for leaked or idle pooled connections first.

What can go wrong

Each connection may allocate sort, join and temp buffers; memory use rises with the setting. open_files_limit may also need raising.

The closest setting on other engines

エンジン設定デフォルトRestart
MySQL max_connections this page 151 いいえ
PostgreSQL max_connections 100 はい
SQL Server user connections 0 (= 32767) はい
Oracle processes Set at creation はい

Questions about max_connections

What is the default value of max_connections in MySQL?

151. 151 (MySQL 8.4).

Does changing max_connections 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_connections?

When clients get 'Too many connections' and Max_used_connections reaches the limit. Check for leaked or idle pooled connections first.

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

// one client for every engine

Check max_connections 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.