WordPress database error MySQL server has gone away

MySQL server has gone away“. Replacing a message is “Lost connection to server during query”. Some causes it. In general, if you use shared hosting you can not fix this because it is located in the server.

The most common cause is:

1. Server timeout and close the connection. Each open connection limited to a certain period of time and after about, database server ( MySQL ) will close the connection whether you like it or not. So, if your source code too long processing, longer period of time allows to keep this connection, then if you have a query, you will see this error, because at this time the connection was automatically closed and refuse any queries related to MySQL from your user.

2. Another common reason is that when the MySQL query error happened and MySQL manually close the connection or do you manually close the connection and then try to run a query on the closed connection. This is a simple matter.

3. You got a timeout from the TCP / IP connection with the client on. This can occur if you are using the command: mysql_options (…, MYSQL_OPT_READ_TIMEOUT, …) or mysql_options (…, MYSQL_OPT_WRITE_TIMEOUT, …). In this case, increase the timeout, as described above, can help solve the problem.

4. You have encountered a timeout on the server and the client automatically reconnect to the disabled.

5. You can also get these errors, if you send a request to the server without properly, or too large. If mysqld will receive a packet that is too large or out of order, it assumes that something has gone wrong with the client and closes the connection. If you need big queries (for example, if you are working with big BLOB columns), you can increase the query limit by setting the value of max_allowed_packet increase, which has a default value of 1MB. ( The default configuration of shared hosting Hostvn.net is 256Mb )

6. INSERT or replace a query insert many rows can also cause these types of errors. Or is one of those words sends a query request to the server regardless of the number of rows will be inserted in, so, you can often avoid the error by reducing the number of rows sent per INSERT or replace.

7. You also get a lost connection if you are sending a package 16MB or larger, if your client is older than 4.0.8 and your server is 4.0.8 more, or any other similar.

VN:F [1.9.22_1171]
Rating: 4.9/5 (4 votes cast)

WordPress database error MySQL server has gone away, 4.9 out of 5 based on 4 ratings