詳細(xì)說(shuō)明mysql連接數(shù)設(shè)置設(shè)置方法(Too many connections)
發(fā)表時(shí)間:2023-09-10 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]下面小編就為大家?guī)?lái)一篇mysql連接數(shù)設(shè)置操作方法(Too many connections)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧mysql在使用過(guò)程中,發(fā)現(xiàn)連接數(shù)超了~~~~[root@linux-node1 ~]# mysql -u glance -...
下面小編就為大家?guī)?lái)一篇
mysql連接數(shù)設(shè)置操作方法(Too many connections)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
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ù):
LimitNO
FILE
=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
+-----------------+-------+
以上就是詳細(xì)介紹mysql連接數(shù)設(shè)置操作方法(Too many connections)的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
學(xué)習(xí)教程快速掌握從入門到精通的SQL知識(shí)。