如何修改Linux下MySQL5.0的默認連接數(shù)
發(fā)布時間:2008/8/21 0:00:00 訪問次數(shù):532
這段時間服務器崩潰2次,一直沒有找到原因,今天看到論壇發(fā)出的錯誤信息郵件,想起可能是mysql的默認連接數(shù)引起的問題,一查果然,老天,默認 連接數(shù)才100, 怎么夠呀,在網上找了半天資料,有說修改my.cnf的,有說修改safe_mysqld,試了,前者無用,
后者文件找不到:)原來是以前的版本跟現(xiàn)在的版本有所不同。
言歸正傳,我以centos 4.4 下面的mysql 5.0.33 手工編譯版本為例說明:
vi /usr/local/mysql/bin/mysqld_safe
找到safe_mysqld編輯它,找到mysqld啟動的那兩行,在后面加上參數(shù):
-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數(shù)據(jù)庫賬號的密碼后可看到
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可以獲得同樣的效果。
欲知詳情,請登錄維庫電子市場網(www.dzsc.com)
這段時間服務器崩潰2次,一直沒有找到原因,今天看到論壇發(fā)出的錯誤信息郵件,想起可能是mysql的默認連接數(shù)引起的問題,一查果然,老天,默認 連接數(shù)才100, 怎么夠呀,在網上找了半天資料,有說修改my.cnf的,有說修改safe_mysqld,試了,前者無用,
后者文件找不到:)原來是以前的版本跟現(xiàn)在的版本有所不同。
言歸正傳,我以centos 4.4 下面的mysql 5.0.33 手工編譯版本為例說明:
vi /usr/local/mysql/bin/mysqld_safe
找到safe_mysqld編輯它,找到mysqld啟動的那兩行,在后面加上參數(shù):
-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數(shù)據(jù)庫賬號的密碼后可看到
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可以獲得同樣的效果。
欲知詳情,請登錄維庫電子市場網(www.dzsc.com)