Getting MySql error

  • Posted June 20, 2019
  • MySQL

Here is the complete error that I’m getting:

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

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

Warning: mysql_connect(): 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!


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

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.


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! Bobby

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.