如何加大MYSQL的连接数
时间:2007-12-26 来源:jybjsrg
1 动态调整
mysql> show global variables like ‘%max_connections%’;
+—————–+——-+
| Variable_name | Value |
+—————–+——-+
| max_connections | 100 |
+—————–+——-+
1 row in set (0.00 sec)
mysql> set global max_connections=1000;
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like ‘%max_connections%’;
+—————–+——–+
| Variable_name | Value |
+—————–+——–+
| max_connections | 1000 |
+—————–+——–+
1 row in set (0.00 sec)
2 参数调整
修改my.cnf(my.ini)下面max_connections = 1000,需要重新启动MYSQL服务
3修改启动文件
修改你的启动文件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
修改好后启动safe_mysqld &服务