Magento MySQL Database Error: MySQL server has gone away

7. Oktober 2015 at 15:51

sql-statement-mysql

If you get an exception error like this in the Magento Exception-Log-File:

ERR (3): exception ‚PDOException‘ with message ‚SQLSTATE[HY000]: General error: 2006 MySQL server has gone away‘ in …/lib/Zend/Db/Statement/Pdo.php:228 Stack trace:

Explanation: It is clearly visible that this is the MySQL timeout error. When you are using shared hosting and you get the huge traffic, so in this case a huge requests sends to MySQL and your request wait for a long time and finally timeout. Another case, If there is one DB connection and fetch some data from DB and do some stuff longer than DB timeout and now if you try to fetch data with same connection you will get the error MySQL server has gone away.

Solutions: You should use dedicated hosting if you are getting a huge traffic to your website instead of shared hosting. Secondly, you should close the DB connection after fetching data and create new DB connection to fetch data again and close the DB connection. If the problem remain same then you need to increase wait_timeout, connect_timeout and max_allowed_packet in my.ini or my.cnf file.

I have changed my my.ini settings as below:
max_allowed_packet = 32M
wait_timeout = 1800
connect_timeout = 120

To change these in your mysql’s my.cnf/my.ini configuration file follow below steps:
For windows: open mysql-install-dir/bin/my.ini and set wait_timeout = 1800 , max_allowed_packet = 32M and connect_timeout = 120 then save and restart mysql server.

For Linux: open /etc/mysql/my.cnf and set wait_timeout = 1800 , max_allowed_packet = 32M and connect_timeout = 120 then save and restart mysql server.

This solution solved my problem of SQLSTATE[HY000]: General error: 2006 MySQL server has gone away.

Please share this article von facebook & google plus or where you want, thank you!

GD Star Rating
loading...
GD Star Rating
loading...
Magento MySQL Database Error: MySQL server has gone away, 10.0 out of 10 based on 2 ratings