方法:1、利用“set GLOBAL max_connections=链接数”临时修改最大连接数;2、利用“vim /etc/my.cnf1”修改“max_connections”后的内容,保存后并重启mysql服务来永久修改最大连接数。

本教程操作环境:linux7.3系统、mysql8.0.22版本、Dell G3电脑。
客户端登录:
mysql -uroot -p
设置新的最大连接数为1000:
mysql> set GLOBAL max_connections=1000
显示当前运行的Query:
mysql> show processlist
显示当前状态:
mysql> show status
退出客户端:
mysql> exit
查看当前最大连接数:
mysqladmin -uroot -p variables
这个办法治标不治本,重启服务以后最大连接数还是100。这个方法用于紧急扩充最大连接数用,不是长久之计。
查看配置文件位置
/usr/bin/mysql --verbose --help | grep -A 1 'Default optio
Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
服务器首先会读取/etc/my.cnf文件,如果不存在则读取/etc/mysql/my.cnf,再依次读取/usr/etc/my.cnf 、~/.my.cnf
在根路径下查找配置文件:
find / -name my.cnf 结果:/etc/my.cnf
配置
vim /etc/my.cnf
编辑my.cnf在[mysqld]中加入:
max_connections=1000
重启服务
service mysqld restart
查看连接数
mysql -u root -p show variables like 'max_connections';
以上就是linux怎么修改mysql的最大连接数的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号