您当前的位置:首页 > 计算机 > 软件应用 > 数据库 > MySQL

MySQL/MariaDB 数据库之 “Error 1040 too many connection” 解决办法:重启数据库或者修改最大连接数

时间:02-18来源:作者:点击数:
城东书院 www.cdsy.xyz

MySQL/MariaDB 数据库之 “Error 1040 too many connection” 解决办法:重启数据库或者修改最大连接数

第一种解决办法是重启数据库。

第二种解决办法修改最大连接数,步骤如下(以为 MariaDB 例):

1. 先登录

# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 36

Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2. 查询当前最大连接数数值

执行 select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS' 查询。

MariaDB [(none)]> select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS';

+----------------+

| VARIABLE_VALUE |

+----------------+

| 151 |

+----------------+

1 row in set (0.00 sec)

3. 修改最大连接数数值

执行 set global max_connections = <数值> 。

MariaDB [(none)]> set global max_connections = 3600;

Query OK, 0 rows affected (0.00 sec)

4. 再查询看是否修改成功

MariaDB [(none)]> select VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='MAX_CONNECTIONS';

+----------------+

| VARIABLE_VALUE |

+----------------+

| 3600 |

+----------------+

1 row in set (0.00 sec)

修改成功!

注意,如果重启数据库,最大连接数又恢复以前的默认值。

城东书院 www.cdsy.xyz
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门