您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 大连分类信息网,免费分类信息发布

正确修改MySQL最大连接数的三种好用方案

2025/6/9 20:58:22发布7次查看
以下的文章主要介绍的是正确修改mysql最大连接数的三种好用方案,我们大家都知道mysql数据库在安装完之后,默认的mysql数据库,其最大连接数为100,一般流量稍微大一点的论坛或网站这个连接数是远远不够的,增加默认mysql连接数的方法有两个。 方法一: 进入
以下的文章主要介绍的是正确修改mysql最大连接数的三种好用方案,我们大家都知道mysql数据库在安装完之后,默认的mysql数据库,其最大连接数为100,一般流量稍微大一点的论坛或网站这个连接数是远远不够的,增加默认mysql连接数的方法有两个。
方法一:
进入mysql安装目录 打开mysql配置文件 my.ini 或 my.cnf查找 max_connections=100 修改为 max_connections=1000 服务里重起mysql即可
方法二:
mysql最大连接数默认是100客户端登录:
mysql -uusername -ppassword 
设置新的mysql最大连接数为200:
mysql> set global max_connections=200 
显示当前运行的query:
mysql> show processlist 
显示当前状态:
mysql> show status 
退出客户端:mysql> exit
查看当前mysql最大连接数:mysqladmin -uusername -ppassword variables
方法三:
以centos 4.4 下面的mysql 5.0.33 手工编译版本为例说明:
vi /usr/local/mysql/bin/mysqld_safe 
找到safe_mysqld编辑它,找到mysqld启动的那两行,在后面加上参数 :
-o max_connections=1500 
具体一点就是下面的位置:
用红字特别说明:
then $nohup_niceness $ledir/$mysqld  $defaults --basedir=$my_basedir_version  --datadir=$datadir $user_option  --pid-file=$pid_file  --skip-external-locking  -o max_connections=1500 >> $err_log 2>&1 else  eval $nohup_niceness $ledir/$mysqld  $defaults --basedir=$my_basedir_version  --datadir=$datadir $user_option  --pid-file=$pid_file  --skip-external-locking $args  -o max_connections=1500 >> $err_log 2>&1  
保存。
# service mysqld restart  # /usr/local/mysql/bin/mysqladmin -uroot -p variables  
输入root数据库账号的密码后可看到
max_connections 1500 即新改动已经生效。
还有一种方法,
修改原代码:
解开mysql的原代码,进入里面的sql目录修改mysqld.cc找到下面一行:
{max_connections, opt_max_connections,  the number of simultaneous clients allowed., (gptr*) &max_connections,  (gptr*) &max_connections, 0, get_ulong, required_arg, 100, 1, 16384, 0, 1,  0},  
把它改为:
{max_connections, opt_max_connections,  the number of simultaneous clients allowed., (gptr*) &max_connections,  (gptr*) &max_connections, 0, get_ulong, required_arg, 1500, 1, 16384, 0, 1,  0},  
存盘退出,然后./configure ;make;make install可以获得同样的效果。以上的相关内容就是对修改mysql最大连接数的3种方法的介绍,望你能有所收获。
大连分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product