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

 

posted @ 2018-07-17 10:01  KingZhou1990  阅读(3685)  评论(0编辑  收藏  举报