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