[TOC] #### 1. Too many connections --- 運行環(huán)境:Winows11、Phpstudy V8.1.1.3、MySQL 5.7.26 同一時間 MySQL 的連接數(shù)量有限制,當超過上限時將提示下面錯誤信息: ``` 1040 - Too many connections ``` 查看當前最大連接數(shù) ```shell mysql> show variables like '%max_connection%'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 100 | +-----------------+-------+ ``` 修改最大連接數(shù) ``` set global max_connections=500; ``` #### 2. MySQL server has gone away --- 運行環(huán)境: Winows11 + Phpstudy V8.1.1.3 進入 MySQL 命令行后,長時間連接 MySQL 服務但未進行操作,MySQL服務自動斷開,再次執(zhí)行操作時出現(xiàn)以下提示 ``` ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect... Connection id: 2 Current database: liang ``` 查看超時時間兩種寫法(默認超時時間為 120 秒): ``` select @@wait_timeout; show variables like 'wait_timeout'; ``` 當前會話的超時時間設置為 700 秒 ``` set @@wait_timeout = 700; ```