Linux MYSQL命令修改各種連接的這那方法
Linux MYSQL命令更新了很多版本更新,我本人認為Linux MYSQL命令很好使的文件系統(tǒng),在此向大家推薦。如今技術(shù)不斷更新,各種使用文件都已經(jīng)淘汰。我認為還是有很不錯的如Linux MYSQL命令值得大家來運用。今天在配置cacti時,發(fā)現(xiàn)只要增加spine的進程數(shù),就會出錯,從log中看到:SPINE: Poller[0] FATAL: Connection Failed, Error:'1040', Message:'Too many connections' (Spine thread)
查了下,應(yīng)該是默認連接太少,網(wǎng)上搜了下,這樣改:Linux MYSQL命令數(shù)據(jù)庫安裝完成后,默認最大連接數(shù)是100,一般流量稍微大一點的論壇或網(wǎng)站這個連接數(shù)是遠遠不夠的,增加默認Linux MYSQL連接數(shù)的方法有兩個
方法一:進入MYSQL安裝目錄 打開Linux MYSQL命令配置文件 my.ini 或 my.cnf查找 max_connections=100 修改為 max_connections=1000 服務(wù)里重起MYSQL即可
方法二:Linux MYSQL命令的最大連接數(shù)默認是100客戶端登錄:mysql -uusername -ppassword設(shè)置新的最大連接數(shù)為200:mysql> set GLOBAL max_connections=200顯示當(dāng)前運行的Query:mysql> show processlist顯示當(dāng)前狀態(tài):mysql> show status退出客戶端:mysql> exit查看當(dāng)前最大連接數(shù):mysqladmin -uusername -ppassword variables
方法三:以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 即新改動已經(jīng)生效。
還有一種方法,修改原代碼:解開Linux 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},
把Linux MYSQL命令它改為:
- {"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可以獲得同樣的效果。
【編輯推薦】