Question

Apache2 and MySql keep stopping

Posted July 31, 2013 8.1k 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

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.

×
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
20GB SSD DISK
1TB TRANSFER

paul@PaulAsher:~$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
NAME="Ubuntu"
VERSION="12.04.2 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.2 LTS)"
VERSION_ID="12.04"

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?
Thanks
Paul
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:
https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
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

Submit an Answer