MySQL server has gone away Print

  • database, phpmyadmin, performance, guide, howto, solution, zillionkinghost, hosting
  • 0

The connection was lost mid-query.

WHAT IT MEANS

The database closed the connection while the application was using it.

COMMON CAUSES

A query taking longer than the connection timeout A packet larger than the server accepts, usually a very large insert The connection idle too long before being reused The database was restarted

DURING AN IMPORT

The most common context. A large SQL file with very large statements exceeds the packet limit.

Import from the command line instead of phpMyAdmin, or split the file.

DURING NORMAL OPERATION

Usually a long-running query. Find it with the slow query log or a profiling tool.

Adding an index frequently resolves it.

AFTER A PERIOD OF INACTIVITY

Code holding a connection open across a long operation, then trying to use it. Reconnecting rather than assuming the connection is alive resolves this.

IF IT HAPPENS REPEATEDLY

Something specific is triggering it. Note what operation was running.

WHAT TO SEND US

What you were doing, the time, and whether it is reproducible.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot