mysql的最大连接数默认是100, 这个数值对于并发连接很多的数据库应用是远远不够的,当连接请求大于默认连接数后,就会出现无法连接数据库的错误,因此我们需要把它适当调大一些, 有两种办法可以修改最大连接数,一种是修改safe_mysqld,另一种是直接修改原代码并重新编译。下面我们就分别介绍这两种方法: 1.修改safe_mysqld 
找到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  然后关闭mysql重启它,用 
/mysqladmin所在路径/mysqladmin -uroot -p variables  输入root数据库账号的密码后可看到 
| max_connections | 1000 | 
即新改动已经生效。  2.修改原代码 
解开MySQL的原代码,进入里面的sql目录修改mysqld.cc找到下面一行: 
{ "max_connections", (long*) &max_connections,100,1,16384,0,1}, 
把它改为: 
{ "max_connections", (long*) &max_connections,1000,1,16384,0,1}, 
存盘退出,然后./configure ;make;make install可以获得同样的效果