Question

MySQL server has gone away

Hello! While running a PHP script I’ve encountered an error that says the MySQL server has gone away and it’s really getting annoying.

I’ve tried the following things with no success. Add these to /etc/mysql/my.cnf

wait_timeout = 28800
interactive_timeout = 28800
max_allowed_packet	= 256M

I’ve tried adding this to php.ini as well.

mysql.connect_timeout = 240

Nothing seems to work.

Thank you!


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi, what about if the error is in this line?

$link->ssl_set(‘client-key.pem’, ‘client-cert.pem’, ‘ca.pem’, NULL, NULL);

where put this mysql.connect_timeout = 300 default_socket_timeout = 300 lines ?

@matthew6d Create a file that contains the following and call it phpinfo.php and place it in your web root and open your browser to that page.

<?php phpinfo();

Then you will see all parameters used by PHP and you can search for each configuration to see what setting it’s using.