max_connections

USAGE

DETAILS

The max_connections system variable sets the maximum number of clients allowed to connect concurrently.

Memory Usage

When the value of max_connections is increased, the server's memory usage can also increase, because each client connection can require additional memory on the server.

The amount of memory used by each connection depends on the values of several system variables, including, but not limited to:

The amount of memory used by each connections also depends on the features in use by the connection, including, but not limited to:

  • The number of temporary tables being used

  • The complexity of the queries being executed

  • The number of tables being joined by the queries

  • If binary logging is enabled

SYNONYMS

SCHEMA

PARAMETERS

Command-line

--max_connections=#

Configuration file

Supported

Dynamic

Yes

Scope

Global

Data Type

BIGINT UNSIGNED

Minimum Value

10

Maximum Value

100000

Product Default Value

151

SKYSQL

Cloud

SkySQL Topology

ES Ver

Service Default

AWS

Multi-Node Analytics

10.6

151

Single Node Analytics

10.6

151

Replicated Transactions

10.4

480

10.5

480

10.6

480

Single Node Transactions

10.4

480

10.5

480

10.6

480

GCP

Multi-Node Analytics

10.6

151

Single Node Analytics

10.6

151

Replicated Transactions

10.4

480

10.5

480

10.6

480

Single Node Transactions

10.4

480

10.5

480

10.6

480

Cloud

SkySQL Topology

ES Ver

Service Default

AWS

ColumnStore Data Warehouse

10.6

151 (choices: 151, 480, 500, 750, 1000)

Enterprise Server With Replica(s)

10.4

480 (choices: 151, 480, 500, 750, 1000)

10.5

480 (choices: 151, 480, 500, 750, 1000)

10.6

480 (choices: 151, 480, 500, 750, 1000)

Enterprise Server Single Node

10.4

480 (choices: 151, 480, 500, 750, 1000)

10.5

480 (choices: 151, 480, 500, 750, 1000)

10.6

480 (choices: 151, 480, 500, 750, 1000)

GCP

ColumnStore Data Warehouse

10.6

151 (choices: 151, 480, 500, 750, 1000)

Enterprise Server With Replica(s)

10.4

480 (choices: 151, 480, 500, 750, 1000)

10.5

480 (choices: 151, 480, 500, 750, 1000)

10.6

480 (choices: 151, 480, 500, 750, 1000)

Enterprise Server Single Node

10.4

480 (choices: 151, 480, 500, 750, 1000)

10.5

480 (choices: 151, 480, 500, 750, 1000)

10.6

480 (choices: 151, 480, 500, 750, 1000)

PRIVILEGES

EXAMPLES

Set in a Configuration File

A configuration file can persistently set the global value:

[mariadb]
max_connections=1000

After changing a configuration file, the server must be restarted. To change the global value without a server restart, set it with SET GLOBAL too.

Set Dynamically with SET GLOBAL

SET GLOBAL can dynamically set the global value:

SET GLOBAL max_connections = 1000;

This operation requires the SUPER privilege.

When the server is restarted, the change does not persist. To make the change persist on restart, set it in a configuration file too.

Set on the Command-line

When MariaDB Server (mariadbd) is started via the command-line, the --max-connections command-line option can set the global value:

$ mariadbd .. --max-connections=1000 ..

Show Value with SHOW VARIABLES

SHOW GLOBAL VARIABLES can show the global value:

SHOW GLOBAL VARIABLES
   LIKE 'max_connections';

Since this system variable is only global scope, SHOW VARIABLES and SHOW SESSION VARIABLES also show the global value.

Query Value using @@global and @@session

In SELECT and other SQL statements, @@global can be queried for the global value:

SELECT @@global.max_connections;

Since this system variable is only global scope, @@session can't be queried for this variable.

Information Schema

The information_schema.SYSTEM_VARIABLES table can be queried to obtain details about the system variable:

SELECT *
FROM information_schema.SYSTEM_VARIABLES
WHERE VARIABLE_NAME LIKE 'max_connections';

The information_schema.GLOBAL_VARIABLES table can be queried to obtain the global value:

SELECT *
FROM information_schema.GLOBAL_VARIABLES
WHERE VARIABLE_NAME LIKE 'max_connections';

This system variable is only global scope, so the information_schema.SESSION_VARIABLES table can also be queried to obtain the global value:

SELECT *
FROM information_schema.SESSION_VARIABLES
WHERE VARIABLE_NAME LIKE 'max_connections';

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

10.6 Enterprise

  • Present starting in MariaDB Enterprise Server 10.6.4-1.

10.6 Community

  • Present starting in MariaDB Community Server 10.6.0.

10.5 Enterprise

  • Present starting in MariaDB Enterprise Server 10.5.3-1.

10.5 Community

  • Present starting in MariaDB Community Server 10.5.0.

10.4 Enterprise

  • Present starting in MariaDB Enterprise Server 10.4.6-1.

10.4 Community

  • Present starting in MariaDB Community Server 10.4.0.

10.3 Enterprise

  • Present starting in MariaDB Enterprise Server 10.3.16-1.

10.3 Community

  • Present starting in MariaDB Community Server 10.3.0.

  • Minimum value changed in MariaDB Community Server 10.3.6 from 1 to 10

10.2 Enterprise

  • Present starting in MariaDB Enterprise Server 10.2.25-1.

10.2 Community

  • Present starting in MariaDB Community Server 10.2.0.

  • Minimum value changed in MariaDB Community Server 10.2.15 from 1 to 10

Release Series

History

10.6 Enterprise

  • Present starting in MariaDB Enterprise Server 10.6.4-1.

10.5 Enterprise

  • Present starting in MariaDB Enterprise Server 10.5.3-1.

10.4 Enterprise

  • Present starting in MariaDB Enterprise Server 10.4.6-1.

EXTERNAL REFERENCES