MySQL 預設 max_connections=100,高併發場景遠遠不足。提供兩種修改方法:
safe_mysqld,找到 mysqld 啟動的兩行命令。-O max_connections=1000 (或更大值)。# 原始
nohup $ledir/mysqld --basedir=... --datadir=... --skip-locking >> $err_log 2>&1
# 修改後
nohup $ledir/mysqld --basedir=... --datadir=... --skip-locking -O max_connections=1000 >> $err_log 2>&1
# 帶參數啟動的情況
nohup $ledir/mysqld --basedir=... --datadir=... --skip-locking "$@" -O max_connections=1000 >> $err_log 2>&1
mysqladmin -u root -p variables 驗證:| max_connections | 1000 |
sql 目錄編輯 mysqld.cc。{ "max_connections", (long*) &max_connections, 100, 1, 16384, 0, 1 },100 改為 1000 (或所需值)。./configure; make; make install 重新編譯安裝。ulimit -n)。