Technology Sharing

Common MySQL errors and solutions

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

1. Too many connections

Operating environment: Winows11, Phpstudy V8.1.1.3, MySQL 5.7.26

There is a limit on the number of MySQL connections at the same time. When the limit is exceeded, the following error message will be displayed:

 
  1. 1040 - Too many connections

View the current maximum number of connections

 
  1. mysql> show variables like '%max_connection%';
  2. +-----------------+-------+
  3. | Variable_name | Value |
  4. +-----------------+-------+
  5. | max_connections | 100 |
  6. +-----------------+-------+

Modify the maximum number of connections

 
  1. set global max_connections=500;
2. MySQL server has gone away

Operating environment: Winows11 + Phpstudy V8.1.1.3

After entering the MySQL command line, if you connect to the MySQL service for a long time without performing any operation, the MySQL service will be automatically disconnected. When you perform the operation again, the following prompt will appear:

 
  1. ERROR 2006 (HY000): MySQL server has gone away
  2. No connection. Trying to reconnect...
  3. Connection id: 2
  4. Current database: liang

Check out the two ways to write the timeout (the default timeout is 120 seconds):

 
  1. select @@wait_timeout;
  2. show variables like 'wait_timeout';

The current session timeout is set to 700 seconds

 
  1. set @@wait_timeout = 700;