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)臨時(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ù)庫最大連接數(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)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
MySQL 數(shù)據(jù)恢復(fù)的多種方法匯總
日常工作中,總會(huì)有因手抖、寫錯(cuò)條件、寫錯(cuò)表名、錯(cuò)連生產(chǎn)庫造成的誤刪庫表和數(shù)據(jù)的事情發(fā)生。但是,如果每次刪庫都跑路的話,怕是再也不好找工作了吧!所以,刪庫跑路不是上上策2021-06-06
MySQL快速插入大量數(shù)據(jù)的解決方案和代碼示例
在這篇博客中,我們將深入探討如何高效插入大量數(shù)據(jù)到MySQL數(shù)據(jù)庫,無論你是數(shù)據(jù)庫新手還是經(jīng)驗(yàn)豐富的開發(fā)者,這篇文章都將為你提供實(shí)用的解決方案和代碼示例,幫助你解決插入3萬條數(shù)據(jù)需要20多秒的問題,需要的朋友可以參考下2024-08-08
mysql無法啟動(dòng)服務(wù)及其他問題總結(jié)
MySQL無法啟動(dòng),可能有多種原因?qū)е?本文主要介紹了mysql無法啟動(dòng)服務(wù)及其他問題總結(jié),具有一定的參考價(jià)值,感興趣的可以了解一下2024-01-01
linux下mysql數(shù)據(jù)庫單向同步配置方法分享
mysql數(shù)據(jù)庫單向同步又叫做主從復(fù)制,是通過二進(jìn)制日志文件完成的,注意:mysql 數(shù)據(jù)庫的版本,兩個(gè)數(shù)據(jù)庫版本要相同2012-06-06
MySQL?8.0?對(duì)?limit?的優(yōu)化技巧
從不同版本的 MySQL 發(fā)展軌跡來看 MySQL 的優(yōu)化器越來越智能 (比如大家期待已久的直方圖特性) ,能更多的減少人為干預(yù),提升執(zhí)行計(jì)劃的準(zhǔn)確性,這篇文章主要介紹了MySQL?8.0?對(duì)?limit?的優(yōu)化,需要的朋友可以參考下2022-10-10

