Question

Restarted droplet and now "Unable to establish database connection" - tried to restart mysql and says can't start

Hi. I recently rebooted my droplet due to some issues with performance. Now after rebooting and restarting Nginx and PHP-FPM the website is still down. I tried to restart mySQL but I get the message “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)”

Any help would be really appreciated as the site is completely down and I’m being flooded with emails of complaint.

Kind regards


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Accepted Answer

Thanks for you help. Unfortunately this didn’t fix things and ultimately I’ve had to restore to a snapshot to fix the issue which is unfortunate as I’ve lost a week of work :| I’m going to get some specialist database input moving forwards, lesson learned.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

What operating system are you in? Please type in on shell and paste back here:

cat /etc/*-release

It should not be mysql you should check because that program is the MySQL client. You need to check if the service is running. Try:

sudo service mysqld status

When I type sudo service mysql status I get the response:

mysql stop/waiting

It seems that the MySQL server is not started or does not exist. Please check that you have installed (previously uninstalled perhaps?) MySQL server and that it is running properly. One way to check if MySQL is running is by running any of the following commands:

# ps aucx | grep mysqld
/etc/init.d/mysqld status
sudo service mysqld status

If you are running systemd systems:

sudo systemctl status mysqld.service