Recently used Mysql Database for multiple programming operations error :ERROR 1040: Too many connections . There are too many connections , The inspection found that Mysql The default number of connections for is 151, It can be modified according to the actual situation .

1、 View the maximum number of connections settings
mysql -uroot -p

MariaDB [(none)]>  show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+
1 row in set (0.01 sec)
2、 Check the maximum number of connections actually used

It can be found that the actual number of connections has reached the maximum number limit

MariaDB [(none)]> show global status like 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 152   |
+----------------------+-------+
1 row in set (0.01 sec)
3、 Modify the maximum number of connections according to actual needs

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

MariaDB [(none)]>  show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 4096  |
+-----------------+-------+
1 row in set (0.01 sec)
4、 Run the error procedure again , Check the maximum number of connections used
MariaDB [(none)]> show global status like 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 1002  |
+----------------------+-------+
1 row in set (0.01 sec)