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