出现Too many connections错误,怎样解决?

本文介绍了如何通过修改MySQL配置文件my.ini来增加最大连接数(max_connections)以支持高并发场景,确保服务稳定运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

怎样增加mysql的max_connections,mysql连接数默认是100, 这个数值对于并发连接很多的数据库应用是不够的,可是怎样把它适当调大呢?

找到safe_mysqld的位置,然后编辑它,找到mysqld启动的那两行,在后面加上参数
-O max_connections=1000
例如
--- safe_mysqld.orig Mon Sep 25 09:34:01 2000
+++ safe_mysqld Sun Sep 24 16:56:46 2000
@@ -109,10 +109,10 @@
if test "$#" -eq 0
then
nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \
- --skip-locking $err_log 2&1
+ --skip-locking -O max_connections=1000 $err_log 2&1
else
nohup $ledir/mysqld --basedir=$MY_BASEDIR_VERSION --datadir=$DATADIR \
- --skip-locking "$@" $err_log 2&1
+ --skip-locking "$@" -O max_connections=1000 $err_log 2&1
fi
if test ! -f $pid_file # This is removed if normal shutdown
then

这个办法有问题,设置后不起作用,下面的方法可以:

找到my.ini(在windows\下,没有就在mysql\下找)

打开它

[mysqld]
set-variable    = max_connections=16384

其中max_connections=16384就是.

转载于:https://www.cnblogs.com/loyou/archive/2007/03/06/665978.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值