[TOC] #### 1. Too many connections --- 运行环境:Winows11、Phpstudy V8.1.1.3、MySQL 5.7.26 同一时间 MySQL 的连接数量有限制,当超过上限时将提示下面错误信息: ``` 1040 - Too many connections ``` 查看当前最大连接数 ```shell mysql> show variables like '%max_connection%'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 100 | +-----------------+-------+ ``` 修改最大连接数 ``` set global max_connections=500; ``` #### 2. MySQL server has gone away --- 运行环境: Winows11 + Phpstudy V8.1.1.3 进入 MySQL 命令行后,长时间连接 MySQL 服务但未进行操作,MySQL服务自动断开,再次执行操作时出现以下提示 ``` 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; ```