首先看看本身的系統版本和Mysql版本,看是否是和個人同樣,若是不同的話,我並不能保證個人方法必定會成功mysql
系統版本:sql
uname -a Linux ubuntu 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
mysql版本:shell
mysql --version mysql Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using EditLine wrapper
如下操做須要有root權限ubuntu
好比說我想將max_connections
改成2000,max_user_connections
改成1000vim
進入/etc/mysql/mysql.conf.d目錄,編輯mysqld.cnfbash
cd /etc/mysql/mysql.conf.d vim mysqld.cnf
在最後加上兩行app
max_connections = 2000 max_user_connections = 1000
重啓mysqlrest
service mysql restart
進入mysqlcode
mysql -u root -p
查看conn是否發生了變化get
show global variables like "%conn%";
在個人電腦上雖然max_user_connections成功變成了1000,可是max_connections卻只爲151,若是想讓它變成2000,還須要修改系統配置
cd /etc/systemd/system/multi-user.target.wants vim mysql.service
在最後面加上這兩行
LimitNOFILE=65535 LimitNPROC=65535
以後重啓服務
systemctl daemon-reload systemctl restart mysql.service
再次進入mysql,看當作功了沒有?