mysql 修改最大连接数max_connections
- 1、编辑mysql service文件
 - 2、编辑mysql 配置文件
 - 3、重启MySQL服务
 - 4、查看max_connections
 
1、编辑mysql service文件
查找mysql service文件
find / -name mysql*.service
 

先备份再编辑
cp /usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/mysqld.service.bak
 
vi /usr/lib/systemd/system/mysqld.service
 
修改LimitNOFILE = XXX 为 LimitNOFILE = infinity
 
2、编辑mysql 配置文件
查找mysql 配置文件
find / -name my*.cnf
 

先备份再编辑
cp /etc/my.cnf /etc/my.cnf.bak
 
vi /etc/my.cnf
 
添加一行max_connections=10000 表示修改成10000
max_connections=10000
 

3、重启MySQL服务
systemctl restart mysqld.service
 
4、查看max_connections
登录MySQL
mysql -uroot -p
 
show variables like '%max_connections%';
 




















