后者文件找不到:)原來是以前的版本跟現在的版本有所不同。
言歸正傳,我以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可以獲得同樣的效果。
下一篇 新手菜鳥做網站推廣的必備素質