• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

详细介绍mysql连接数设置操作方法(Too many connections)

mysql 搞代码 4年前 (2022-01-09) 10次浏览 已收录 0个评论

下面小编就为大家带来一篇mysql连接数设置操作方法(Too many connections)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

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

[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -pEnter password:ERROR 1040 (08004): Too many connections

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

1)临时修改

MariaDB [(none)]> show variables like "max_connections";+-----------------+-------+| Variable_name | Value |+-----------------+-------+| max_connections <strong style="color:transparent">本文来源gaodai#ma#com搞@@代~&码网^</strong>| 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=10000LimitNPROC=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)的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:详细介绍mysql连接数设置操作方法(Too many connections)

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址