ERROR 1040 (HY000): Too many connections
max_connections 設定過低(預設 100/151),或應用程式連接洩漏、未釋放。
SET GLOBAL max_connections = 1000;
但重啟後失效,必須修改配置檔。
[mysqld]
max_connections = 1000
重啟服務:
net stop mysql
net start mysql
[mysqld]
max_connections = 1000
重啟:systemctl restart mysqld 或 /etc/init.d/mysql restart
[mysqld]
max_connections = 1500
thread_cache_size = 64
table_open_cache = 2048
open_files_limit = 65535
# InnoDB 核心
innodb_buffer_pool_size = 70% 實體記憶體
innodb_log_file_size = 512M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_thread_concurrency = 0
# 連接超時
wait_timeout = 60
interactive_timeout = 60
max_allowed_packet = 64M
maximumPoolSize < max_connectionsThreads_connected、Threads_running、Connection_errors_max_connections修改 innodb_log_file_size 後無法啟動:
data/ib_logfile*調大 max_connections 只治標。根治靠連接池配置、縮短事務、監控洩漏。InnoDB 參數同步調優才能支撐高併發。