mysql在使用過(guò)程中,發(fā)現(xiàn)連接數(shù)超了~~~~
[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -p
Enter password:
ERROR 1040 (08004): Too many connections
解決辦法,這也是centos7下修改mysql連接數(shù)的做法:
1)臨時(shí)修改
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]新添加一行如下參數(shù):
max_connections=1000
重啟mariadb服務(wù),再次查看mariadb數(shù)據(jù)庫(kù)最大連接數(shù),可以看到最大連接數(shù)是214,并非我們?cè)O(shè)置的1000。
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
這是由于mariadb有默認(rèn)打開(kāi)文件數(shù)限制??梢酝ㄟ^(guò)配置/usr/lib/systemd/system/mariadb.service來(lái)調(diào)大打開(kāi)文件數(shù)目。
配置/usr/lib/systemd/system/mariadb.service
[Service]新添加兩行如下參數(shù):
LimitNOFILE=10000
LimitNPROC=10000
重新加載系統(tǒng)服務(wù),并重啟mariadb服務(wù)
systemctl --system daemon-reload
systemctl restart mariadb.service
再次查看mariadb數(shù)據(jù)庫(kù)最大連接數(shù),可以看到最大連接數(shù)已經(jīng)是1000
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
以上這篇mysql連接數(shù)設(shè)置操作方法(Too many connections)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:- Mysql錯(cuò)誤:Too many connections的解決方法
- Mysql 錯(cuò)誤too many connections解決方案
- mysql too many open connections問(wèn)題解決方法
- 解決mysql 1040錯(cuò)誤Too many connections的方法
- mysql "too many connections" 錯(cuò)誤 之 mysql解決方法
- MySQL too many connections錯(cuò)誤的原因及解決