Apache2 and MySql keep stopping

July 31, 2013 4.2k views
I have a DO Droplet server and every day or so I have to restart apache2 and mysql - "CRI: Error connecting to MySQL Server: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) (#2002) - the site owner should contact their hosting provider for assistance." when access the website. Why is this happening, and how to fix it please? Many thanks Pa
7 Answers
How much RAM & how many cores do you have on your droplet? What OS are you running? Have you tweaked apache2.conf or my.cnf at all?
Sorry for the multiple posts - DO kept telling me there was an error when posting and to try again!!!
512MB / 1 CPU

paul@PaulAsher:~$ cat /etc/*-release
VERSION="12.04.2 LTS, Precise Pangolin"
PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"

I followed DO's intructions to the letter when building the server which include tweaking apache2.conf (I think) but do not recall my.cnf changes.
What do I need to do with them to fix this?
As posted in your other topic, check that you are not running out of memory as the server will kill the biggest memory hogs. Check the error logs to see what's going on.

If you haven't added swap memory, try this:
by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
Where is the error log? (Sorry - newbie to server management but a quick learner!!)
Thanks for the swapping link - Might try that after I've checked the logs.
@paul: Error logs are usually found in /var/log. On Ubuntu, MySQL's error log is /var/log/mysql.err

You can output the last few lines of that file using the 'tail' command:

tail /var/log/mysql.err
Thanks for the help. Just waiting for it to stop again now so that I can check the logs. Things never break when you want them to lol

May I revive this topic. My mysql service kept stopping and showing this error to end user

DibiDriverException: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

this command show nothing

tail /var/log/mysql.err

using the lowest DO droplet specs

Please help

Have another answer? Share your knowledge.