Linux CentOS 中設置Mysql 最大連接數 max_connections


 

查詢Mysql當前的最大連接數

mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 150  |
+-----------------+-------+
1 row in set

 

在文件etc/my.cnf中設置Mysql 最大連接數

[mysqld]

max_connections =2000

 

重啟Mysql 命令

$ systemctl restart  mysqld.service

 

查詢Mysql當前的最大連接數,發現最大連接數是214

mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 214  |
+-----------------+-------+
1 row in set

 

更改 MySQL 在 Linux 的最大文件描述符限制,編輯 /usr/lib/systemd/system/mysqld.service 文件,在文件最后添加: 
ubuntu16.04 下面位於:/lib/systemd/system/mysql.servive,可以通過find 命令查找

 

LimitNOFILE=65535
LimitNPROC=65535

保存后,執行下面命令,使配置生效

 

$ systemctl daemon-reload
$ systemctl restart  mysqld.service

實際連接數到 2000 了,解決

mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 2000  |
+-----------------+-------+
1 row in set

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM