假設你的啟動腳本是/etc/init.d/mysql 那麼找到$bindir/safe_MySQLd這行,加上如下參數
-O max_connections=1000 -O wait_timeout=500 -O interactive_timeout=500
當然,得根據你的實際情況加以修改,不過默認值對於我們公司這樣負載的服務器是不可想象的……
現在,你的MySQL啟動文件有可能看起來像這樣:
............
$bindir/safe_mysqld --user=MySQL --datadir=$datadir --pid-file=$pid_file -O max_connections=1000 -O wait_timeout=500 -O interactive_timeout=500&
............
修改完成之後,重啟MySQL即可,注意一定要先使用MySQLadmin shutdown 服務器。
推薦在my.cnf中配置這些參數。
如果你有MySQL的源代碼版本,你可以在support-files目錄下找到my-huge.cnf, my-large.cnf分別打開看看,選擇適合你的那個文件
抄一段話:
# You can copy this file to
# /etc/my.cnf to set global options,
# MySQL-data-dir/my.cnf to set server-specific options (in this
# installation this directory is @localstatedir@) or
# ~/.my.cnf to set user-specific options.
#
# One can in this file use all long options that the program supports.
# If you want to know which options a program support, run the program
# with --help option.