ERROR 1040 (00000): Too many connections
mysql> SHOW VARIABLES LIKE 'max_connections';
mysql> SHOW STATUS LIKE 'Max_used_connections'; -- 歷史峰值
mysql> SHOW STATUS LIKE 'Threads_connected'; -- 當前連線數
[mysqld]
max_connections = 1000
max_user_connections = 300 # 單用戶上限,防單庫佔死
修改後**重啟 MySQL 服務**生效。
[mysqld]
max_connections = 1000
max_user_connections = 300
重啟:systemctl restart mysqld。
mysql> SET GLOBAL max_connections = 1000;
Threads_connected / max_connections > 80% 觸發預警。maxPoolSize < max_connections * 0.7(預留運維/備份連線)。SHOW PROCESSLIST 發現 Sleep 過多連線優化代碼。performance_schema 監控連線創建/銷毀趨勢。