Databases 9 min read

Using MySQL 8.0 Administrative Connection Interface to Solve “Too Many Connections” Errors

The article explains why MySQL can hit the max_connections limit, introduces the MySQL 8.0 administrative connection interface and its configuration variables, demonstrates how to create a privileged user and test connection limits with code examples, and offers best‑practice recommendations to prevent connection saturation.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Using MySQL 8.0 Administrative Connection Interface to Solve “Too Many Connections” Errors

Author: Yang Taotao – senior database expert with over ten years of MySQL experience.

Why the "Too many connections" error occurs

When a client encounters ERROR 1040 (HY000): Too many connections , the root causes are often:

Applications use an ALL‑privileges account instead of limited users.

DBAs create multiple ALL‑privileges accounts for developers and operations.

The MySQL server itself lacks a connection pool, causing request buildup.

Applications connect directly to MySQL without a client‑side pool.

The max_connections setting is too low for the actual workload.

If a dedicated administrator account exists, MySQL reserves one extra connection for admin use, but many deployments share a single admin user, so the DBA must manually increase max_connections when the limit is reached.

MySQL 8.0 Administrative Connection Interface

MySQL 8.0 provides an administrative connection interface that is not limited by the usual connection count (hardware limits still apply). The relevant global variables start with admin_ :

admin_address : IP or hostname for the interface (single value).

admin_port : Listening port, default 33062 .

admin_ssl* and admin_tsl* : Optional SSL settings.

create_admin_listener_thread : Whether to run a dedicated listener thread.

To use the interface, a user must have the SUPER static privilege or the service_connection_admin dynamic privilege.

Step‑by‑step usage

1. Verify the admin variables are enabled:

localhost:(none)> select @@admin_address, @@admin_port, @@create_admin_listener_thread;
+-----------------+--------------+--------------------------------+
| @@admin_address | @@admin_port | @@create_admin_listener_thread |
+-----------------+--------------+--------------------------------+
| debian-ytt1     |        18027 |                              1 |
+-----------------+--------------+--------------------------------+
1 row in set (0.00 sec)

2. Create a user with the service_connection_admin privilege:

localhost:(none)> create user ytt_admin;
Query OK, 0 rows affected (0.02 sec)
localhost:(none)> grant select, insert, update, delete, service_connection_admin on *.* to ytt_admin;
Query OK, 0 rows affected (0.02 sec)

3. Reduce max_connections to 1 to illustrate the effect (admin gets 2 connections, normal users get 1):

localhost:(none)> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
|                 1 |
+-------------------+
1 row in set (0.00 sec)

4. The new user ytt_admin can open two connections, but the third attempt fails:

root@debian-ytt1:~/sandboxes/msb_8_0_25# mysql -uytt_admin -P 8025 -h debian-ytt1 -e "select sleep(3600)" &
[1] 7474
root@debian-ytt1:~/sandboxes/msb_8_0_25# mysql -uytt_admin -P 8025 -h debian-ytt1 -e "select sleep(3600)" &
[2] 7475
root@debian-ytt1:~/sandboxes/msb_8_0_25# mysql -uytt_admin -P 8025 -h debian-ytt1 -e "select sleep(3600)" &
[3] 7477
root@debian-ytt1:~/sandboxes/msb_8_0_25# ERROR 1040 (HY000): Too many connections
[3]+ 退出 1                mysql -uytt_admin -P 8025 -h debian-ytt1 -e "select sleep(3600)"

5. Connect through the admin interface (port 18027 ):

root@debian-ytt1:~/sandboxes/msb_8_0_25# mysql -h debian-ytt1 -uytt_admin -P 18027 -e "select sleep(3600)" &
[3] 8516

6. View active connections (still using the admin interface):

root@debian-ytt1:~/sandboxes/msb_8_0_25# mysql -h debian-ytt1 -uytt_admin -P 18027 -e "show processlist;" -ss
8  ytt_admin ... Query 154 User sleep select sleep(1000)
9  ytt_admin ... Query 148 User sleep select sleep(3600)
13 ytt_admin ... Query 138 User sleep select sleep(3600)
17 ytt_admin ... Query 0   init  show processlist

The admin interface, like the legacy reserved admin connection, requires sufficient hardware resources; otherwise the server may reject connections (e.g., ERROR 2003 (HY000): Can't connect to MySQL server ).

Long‑term solutions

While the admin interface offers a handy workaround, the fundamental fix is to reduce the number of incoming requests before they reach the database:

Assign clear permissions; only administrators receive SUPER rights.

Apply rate‑limiting at the application layer based on performance testing.

Optimize SQL statements and table schemas for maximum efficiency.

Shard databases or tables and use distributed architectures to spread load.

These practices help avoid hitting the connection limit in the first place.

Performance TuningMySQLDatabase Administrationconnection poolingmax_connectionsAdministrative Connection Interface
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.