mysql資料庫預設的最大串連資料為100,如果我們要修改可以利用兩種方式,一種是set GLOBAL max_connections命令執行,另一種是 開啟MySQL設定檔 my.ini 或 my.cnf尋找 max_connections=進行修改,下面我們來看看。
查看mysql最大串連資料
| 代碼如下 |
|
|
show variables like '%max_connections%' |
修改方法:
進入mysql終端,
| 代碼如下 |
|
|
mysql > set GLOBAL max_connections=1000;
mysq > show variables like '%max_connections%'; |
當然,你也可以直接修改mysql設定檔。進入MySQL安裝目錄 開啟MySQL設定檔 my.ini 或 my.cnf尋找 max_connections=100 修改為 max_connections=1000 服務裡重起MySQL即可。
注意:MySQL伺服器允許的最大串連數16384
另一種在linux系統中的方法
以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 |