Max_allowed_packet is the maximum size of one packet. To be throughout, also adjust max_execution_time and max_input_time still in php.ini, if necessary. If PHP’s execution time is longer than max_execution_time, then MySQL server might disconnect. This default applies to all streams that set no other timeout value. mysqlnd does not set any other value and therefore connections of long running queries can be disconnected after default_socket_timeout seconds resulting in an error message 2006 – MySQL Server has gone away.” default_socket_timeout=90 This is set via php.ini, default_socket_timeout. “PHP, by default, sets a read timeout of 60s for streams. Before you send hate mail, please read here first. Eventually, it quits with the “MySQL server has gone away” error. Creating a wait that utilizes the default_socket_timeout. IMPORTANT: Read first about PHP Persistent Database Connections to understand the benefits and caveats.Īlso, adjust PHP’s default_socket_timeout. For example, a PHP script could be running a slow query. It’s also when waiting for the first response from the MySQL server. Try increasing nnect_timeout to match or exceed your MySQL wait_timeout and make sure that mysql.allow_persistent is on (default = enabled). Make sure the nnect_timeout setting isn’t set lower than MySQL wait_timeout, discussed above. The PHP option nnect_timeout is not only used for connect timeout. ![]() Adjust or add the following lines in my.cnf to meet your requirements: wait_timeout=90 Also, check the variables: net_read_timeout, net_write_timeout and interactive_timeout. That said, the lower you can set wait_timeout without affecting database connections, can be a good sign of MySQL database efficiency. The default for MySQL wait_timeout is 28800 seconds. You should make sure the wait_timeout is not set too low. MySQL wait_timeout is the number of seconds the server waits for activity on a non-interactive connection before closing it. The reason for MySQL server has gone away error is often because MySQL’s wait_timeout was exceeded. Lost connection to MySQL server during query Warning: Error while sending QUERY packet PDOException: SQLSTATE: General error: 2006 MySQL server has gone away With this in mind, here are error log examples of the MySQL server has gone away error: General error: 2006 MySQL server has gone away Error Code: 2013. Application Performance Monitoring solutions and PHP Stack trace tools can be of help. In which case, you need to check ALL related error logs with the same timestamp to determine whether another issue may be to blame. Meaning the error could be due to a problem or bug in your connecting application or remote service. In addition, at times, the error is only an indication of a deeper underlying issue. Keep in mind that this error can be logged in a few ways, as listed below. MySQL server has gone away error log examples. If you’ve found a solution not listed or linked to on this page, please send me a note or leave a comment. ![]() This article includes solutions I’ve seen for this MySQL server general error. ![]() This is partly because to solve this error sometimes the solution involves multiple layers, application, or service config changes. MySQL server has gone away, can be a frustrating error to solve.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |