Wednesday, July 04, 2012

Magento - Lost connection to MySQL server

I have been facing this issue for past few hours when I tried to do a bulk insert from Magento database through a custom module to our DWH. Datawarehouse is running MYSQL server on CentOS 6.2. I was doing a full dump of customers, products and orders from our Magento store to the Datawarehouse for the first time. But I couldn't  even get  more than 2k customers to the DWH database. Magento module returns an error "Error 2013 : Lost connection to MySQL server".

After doing some reading on the internet I found that, this is nothing to do with Magento or my custom module. It was just the way MYSQL server was configured.  Luckily it was a easy fix :).  Just change the max_allowed_packet parameter.

In CentOS go to /etc/my.cnf and add or edit the following under [mysqld] section
[mysqld]
max_allowed_packet= 16M 

I had 16M to suit my particular situation, choose a value that suites you. This should work, at least it worked for me ;), also recommend to have look at the wait_timeout parameter as well since few people mentioned that as well.

No comments: