Problem like this can happen if MySQL is not running. You should check it's status by using systemctl command:
- sudo systemctl status mysql
If you are using Ubuntu 14.04, above command will not work and you'll have to use:
- sudo service mysql status
If you see that it's stopped or failed try to start it again to see will it come up:
- sudo systemctl start mysql
Check status once again. If it's running, try accessing it. In that case you need to analyze logs to see why it went down.
If not, did you change something in MySQL configuration? If yes, revisit it and make sure you didn't make any mistake.
If starting service worked, to prevent this happening, you have to check log files.
Usual reason why MySQL goes down is that it went out-of-memory.
Take a look at system log -
- sudo nano /var/log/syslog
If you find there any OOM, out of memory, OOM killer entries that means MySQL went down due to out-of-memory. In that case consider upgrading Droplet or installing Swap.
If not, look around and see is there any other MySQL error.
One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. In this guide, we will cover how to add a swap file to an Ubuntu 16.04 server. <$>[warning] [label...