Getting MySql error

June 20, 2019 237 views

Here is the complete error that I'm getting:

Warning: mysqlirealconnect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) in /var/www/ on line 1603

Deprecated: mysqlconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /var/www/ on line 1633

Warning: mysqlconnect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) in /var/www/ on line 1633

My site auto stopped working after some time and get the above errors. To solve this problem, I need to restart again-n-again MySql servers.

How I can solve this problem so that I do not need to start servers again-n-again.

Thanks in advance!

2 Answers


This sounds like your MySQL server is being killed. Most likely due to the lack of available RAM.

Make sure to optimize your site so it uses less RAM and maybe consider increasing your RAM as well. Another thing you could do is to add a swap file so that there's some buffer.

Hope that this helps!

We can display error message in case of an error generated by mysql query. This meaning full error message gives idea one the problem or bugs in the script. We can print the error message by using mysql function mysql_error(). This function returns the error message associated with most recently executed query.

Have another answer? Share your knowledge.