mysql 数据库出现too many connections

 

重启数据库 service mariadb restart

出现权限不够问题

在命令前加sudo 执行成功

编辑数据库的my.cnf文件 权限不够 在编辑前加sudo

 

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 | 

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值