Skip to content

Tshoot: Too many connection mariadb

Published: at 12:59 PMSuggest Changes

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1691758725518/7908fb2b-9e8a-4e98-bb7d-1c544d61085b.png align=“center”)

Cause: mysql has a max_connection variable where connections to mysql cannot exceed the value of the variable.

Solution: increase the value of the max_connection variable

1. Check max_connections configured

mysql

MariaDB [(none)]> show variables like "%connection%";
+---------------------------+--------------------+
| Variable_name             | Value              |                                                                                                                                            +---------------------------+--------------------+                                                                                                                                            | character_set_connection  | utf8mb4            |
| collation_connection      | utf8mb4_general_ci |                                                                                                                                            | default_master_connection |                    |
| extra_max_connections     | 1                  |
| max_connections           | 151                |
| max_user_connections      | 0                  |
+---------------------------+--------------------+

2. Check max used connections and connection error:

MariaDB [(none)]> show global status like "%connections%";                                                                                                                                    +-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| Connection_errors_max_connections | 64    |                                                                                                                                                 | Connections                       | 6613  |
| Max_used_connections              | 152   |
| Slave_connections                 | 0     |
| wsrep_open_connections            | 0     |                                                                                                                                                 +-----------------------------------+-------+

3. Increase max connection

MariaDB [(none)]> SET GLOBAL max_connections=4096;
Query OK, 0 rows affected (0.000 sec)

4. Check again

MariaDB [(none)]> show variables like "%connection%";
+---------------------------+--------------------+                                                                                                                                            | Variable_name             | Value              |                                                                                                                                            +---------------------------+--------------------+
| character_set_connection  | utf8mb4            |                                                                                                                                            | collation_connection      | utf8mb4_general_ci |
| default_master_connection |                    |
| extra_max_connections     | 1                  |
| max_connections           | 4096               |
| max_user_connections      | 0                  |
+---------------------------+--------------------+

Previous Post
#1 Pengenalan - Belajar Docker
Next Post
Tshoot: Remove warning cryptography openstack client