前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mysql连接数设置操作(Too many connections)

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

作者头像
洗尽了浮华
发布2018-01-23 11:24:27
2.1K0
发布2018-01-23 11:24:27
举报
文章被收录于专栏:散尽浮华散尽浮华

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 | +-----------------+-------+

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-12-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档