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