Page 1 of 1

Error establishing a database connection

Posted: Tue Dec 17, 2013 6:51 am
by nccdebug
Hi everyone,

I get the following error with MySQL; I restarted MySQL server many times it solved the issue for some time, but it keeps coming again:

Magento site: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

Wordpress site: Error establishing a database connection


Please help

Re: Error establishing a database connection

Posted: Wed Dec 18, 2013 8:57 pm
by skid
It look like MySQL server runs out of memory and dies. If you can not increase memory on a server, you can try to decrease memory consumption by tuning my.cnf file. Depending on your operating system config file is located in /etc/mysql/my.cnf or /etc/my.cnf
I suggest to start with decreasing following parameters:
max_connections
max_user_connections

Re: Error establishing a database connection

Posted: Mon Dec 23, 2013 8:10 pm
by nccdebug
Thank you Skid. How about using a swap file? any advantage over "decrease memory consumption by tuning my.cnf file"

Re: Error establishing a database connection

Posted: Tue Dec 24, 2013 2:41 pm
by skid
Well, it's up to you to decide. Sometimes swap can improve overall health.