0

Do you know how to avoid the following fatal error message :

"...MySQL server has gone away".

I suppose this means that PDO connection to MySQL has been lost.

I have checked MySQL max_allowed_packet variable which is equal to 268435456 (I think this value is more than enough).

Paolo
  • 15,233
  • 27
  • 70
  • 91
Jam
  • 1
  • 1

3 Answers3

1

There is no way to "avoid" this error. This error happens when you lose connection to the DB server. This can happen for a variety of reasons. The most common reason for the MySQL server has gone away error, is that the server timed out and closed the connection.

Some other common reasons are:

  • You (or the db administrator) has killed the running thread.
  • You tried to run a query after closing the connection to the server.
  • You got a timeout from the TCP/IP connection on the client side.
  • You have encountered a timeout on the server side and the automatic reconnection in the client is disabled.
  • And more.

Check out this link from the MYSQL docs for more info.

Baasic
  • 86
  • 6
0

You can check the max_connections and make sure they aren´t reached - that´s the most common cause I remember for you to get this error.

Curious Mind
  • 659
  • 10
  • 26
-1

Thanks for your respective answers. After few days of investigations, I decided to reset PDO MySQL connection every 250 seconds. I know it is not the best in class solution but it is at least a solution to avoid the problem.

Jam
  • 1
  • 1