当前位置: 移动技术网 > IT编程>数据库>Mysql > mysql连接数设置操作方法(Too many connections)

mysql连接数设置操作方法(Too many connections)

2017年12月12日  | 移动技术网IT编程  | 我要评论

ntn轴承,兢业金服,怀孕分泌物

mysql在使用过程中,发现连接数超了~~~~

[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -p

enter password:

error 1040 (08004): too many connections

解决办法,这也是centos7下修改mysql连接数的做法:

1)临时修改

mariadb [(none)]> show variables like "max_connections";
+-----------------+-------+
| variable_name | value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in set (0.00 sec)
mariadb [(none)]> set global max_connections=1000;
query ok, 0 rows affected (0.00 sec)
mariadb [(none)]> show variables like "max_connections";
+-----------------+-------+
| variable_name | value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
1 row in set (0.00 sec)

2)永久修改:

配置/etc/my.cnf
[mysqld]新添加一行如下参数:
max_connections=1000
重启mariadb服务,再次查看mariadb数据库最大连接数,可以看到最大连接数是214,并非我们设置的1000。
mariadb [(none)]> show variables like 'max_connections';
+-----------------+-------+
| variable_name | value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
这是由于mariadb有默认打开文件数限制。可以通过配置/usr/lib/systemd/system/mariadb.service来调大打开文件数目。

配置/usr/lib/systemd/system/mariadb.service

[service]新添加两行如下参数:
limitnofile=10000
limitnproc=10000

重新加载系统服务,并重启mariadb服务

systemctl --system daemon-reload
systemctl restart mariadb.service

再次查看mariadb数据库最大连接数,可以看到最大连接数已经是1000

mariadb [(none)]> show variables like 'max_connections';
+-----------------+-------+
| variable_name | value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+

以上这篇mysql连接数设置操作方法(too many connections)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网