时间:2021-07-01 10:21:17 帮助过:16人阅读
最近使用Mysql数据库进行多编程操作时报错:ERROR 1040: Too many connections 。提示连接过多,检查发现Mysql的默认连接数为151,可根据实际情况进行修改。
mysql -uroot -p
MariaDB [(none)]> show variables like ‘max_connections‘;
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.01 sec)
可以发现实际使用的连接数己达到最大连接数限制
MariaDB [(none)]> show global status like ‘Max_used_connections‘;
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Max_used_connections | 152 |
+----------------------+-------+
1 row in set (0.01 sec)
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)
MariaDB [(none)]> show global status like ‘Max_used_connections‘;
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Max_used_connections | 1002 |
+----------------------+-------+
1 row in set (0.01 sec)
修改Mysql最大连接数
标签:数据库 var stat 报错 block maria lob mariadb 查看