2013: Lost connection to MySQL server during query
MySQLWhat does it mean?
The connection between the client and the MySQL server dropped while the query was running. It was cut before the server could respond or return results.
Why does it happen?
A long-running query exceeding net_read_timeout/net_write_timeout; the server terminating the query/connection due to out-of-memory (OOM); a network outage; exceeding max_allowed_packet; the server crashing or restarting; a very large result set.
How to fix it
Check network stability and the server error log; see whether there was an OOM or crash. Increase the timeouts: SET GLOBAL net_read_timeout = 120; Split large queries into batches. Increase max_allowed_packet. Add connection retry logic in the application. Optimize long queries.
More from this engine
- 1305PROCEDURE does not exist
- 1227Access denied; you need (at least one of) the PRIVILEGE
- 3730Cannot drop table referenced by a foreign key constraint
- 1153Got a packet bigger than 'max_allowed_packet' bytes
- 1969MariaDB: Query execution was interrupted (max_statement_time exceeded)
- 1927MariaDB: ER_CONNECTION_KILLED: Connection was killed
- 1290ER_OPTION_PREVENTS_STATEMENT: running with the --read-only option