2006: MySQL server has gone away

1.8k views Asked by At

I am getting 'Lost connection to MySQL server' and '2006: MySQL server has gone away' errors so frequently that the server is unusable. There are questions related to this issue in SO, but none that apply to my situation; for instance, there is no network connection (the server is connected by a socket to the client process which is on the same machine) and there are no long queries (the machine is running a number of CMS - mediawiki, drupal and joomla - and PHPMyAdmin, but there is nothing exceptional about the queries generated, AFAIK).

I have increased all the timeouts to the point where they must surely be sufficient:

+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 60       |
| delayed_insert_timeout      | 300      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 28800    |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 6000     |
| net_write_timeout           | 6000     |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 3600     |
| wait_timeout                | 28800    |
| max_allowed_packet          | 16777216 |
+-----------------------------+----------+

I have also changed the connect_timeout setting in php.ini to unlimited:

; Maximum time (in seconds) for connect timeout. -1 means no limit
; http://php.net/mysql.connect-timeout
mysql.connect_timeout = -1

Restarting the server clears the problem for some hours. After that, every access through the CMSs (i.e. through PHP) and through a small PHP test program with a trivial query fails. However, I can still access the MySQL server and the databases through the MySQL client.

There are no error messages in the MySQL error log.

The server is running on a recent Mac Mini, using Mac OS X 10.9.5, MySQL v5.6.22 and PHP v5.6.3 installed using Mac Port.

Can you help with ideas where I should look to deal with this?

2

There are 2 answers

0
ThakurAnkur On

This error is usually occurs while server time out and may by be connection is closed , So may be http://dev.mysql.com/doc/refman/5.0/en/gone-away.html will help you.

0
Ngugi Kiarie On

In your sql config file, find the property max_allowed_packet and change it from 1M to something higher, 16M worked for me.

Regards.