mysql連接數(shù)設(shè)置操作方法(Too many connections)
mysql在使用過程中,發(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)臨時修改
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ù)庫最大連接數(shù),可以看到最大連接數(shù)是214,并非我們設(shè)置的1000。
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
這是由于mariadb有默認(rèn)打開文件數(shù)限制??梢酝ㄟ^配置/usr/lib/systemd/system/mariadb.service來調(diào)大打開文件數(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ù)庫最大連接數(shù),可以看到最大連接數(shù)已經(jīng)是1000
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
以上這篇mysql連接數(shù)設(shè)置操作方法(Too many connections)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用mysql查詢當(dāng)天、近一周、近一個月及近一年的數(shù)據(jù)
不論你是一名數(shù)據(jù)庫管理員或SQL開發(fā)者,還是一名簡單的MySQL用戶,掌握查詢特定日期數(shù)據(jù)的方法都是必不可少的,下面這篇文章主要給大家介紹了關(guān)于如何使用mysql查詢當(dāng)天、近一周、近一個月及近一年的數(shù)據(jù),需要的朋友可以參考下2023-06-06一文解決連接MySQL報錯is?not?allowed?to?connect?to?this?MySQL?
這篇文章主要給大家介紹了關(guān)于如何通過一文解決連接MySQL報錯is?not?allowed?to?connect?to?this?MySQL?server的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下2023-08-08mysql如何修改表結(jié)構(gòu)(alter table),多列/多字段
這篇文章主要介紹了mysql如何修改表結(jié)構(gòu)(alter table),多列/多字段問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-12-12CentOS 7 中以命令行方式安裝 MySQL 5.7.11 for Linux Generic 二進(jìn)制版本教程詳解
MySQL 目前的最新版本是 5.7.11,在 Linux 下提供特定發(fā)行版安裝包(如 .rpm)以及二進(jìn)制通用版安裝包(.tar.gz)。這篇文章主要介紹了CentOS 7 中以命令行方式安裝 MySQL 5.7.11 for Linux Generic 二進(jìn)制版本教程詳解的相關(guān)資料,需要的朋友可以參考下2016-10-10