MySQL server has gone away
Jump to:
Project: | Programming |
Component: | Code |
Category: | support request |
Priority: | normal |
Assigned: | Unassigned |
Status: | closed |
Related pages: | #50: MySQL server has gone away |
Description
I have a php CLI script which takes more than 8 hours, which is longer than the default timeout for the mysql.
As a result, I have the following error by the end of my script:
MySQL server has gone away
I'm finding information about everywhere in the internet. I'll compile what I find in the wiki.
Comments
#1
20.8.11. Controlling Automatic Reconnection Behavior
http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html
The problem is that the solution offered implies being able to change the code. I could do that but I'd need to patch Drupal core, which I'd rather not do.
I'm looking for a solution that I could set in my.cnf or in php.ini.
#2
a php.ini setting is available with mysqli.
See #52: Mysql and Mysqli php extensions for server setting questions.
#3
http://drupal.org/node/227445#comment-1042291
#4
Apparently on Ubuntu, the mysqli extensions are installed together with php5-mysql.
So, in my case, I only needed to adapt the settings.php for my Drupal site to use the mysqli instead of mysql.
Also, I had to change the default php.ini:
/etc/php5/cli/php.ini
; Allow or prevent reconnect
mysqli.reconnect = On
#5
The problem is fixed for me, and I put in the wiki the information I found.
#6
Automatically closed -- issue fixed for 2 weeks with no activity.