MySQL server has gone away (PHP)

Author: Zeeshan Arshad     1549     10/18/2011

Estimated reading time: 0 minutes, 18 seconds

Problem: Server returns the error "Mysql server has gone away" when running a large set of queries (specially as a Cronjob).

 

Solution: Simply copy/paste the following lines in beginning of your php file.

 

ini_set('mysql.connect_timeout', 300);
ini_set('default_socket_timeout', 300);

 

Reason: The mysql.connect_timeout option is the reason for this.


Was this topic helpful?

Yes
No
Subscribe YouTube Channel

Zeeshan Arshad is a self-taught and multi-dimensional person with extraordinary track record of success with international clients and students.

Feel free to contact him for your project, training purpose or guidance.