I restored my Magento site from yesterdays Digital Ocean backup and now can't connect to database. Does anyone have any ideas on fix?

August 9, 2016 314 views
Backups MySQL Ubuntu

when trying to connect to mysql database while in Putty, I get the following:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

1 Answer

Try starting your MySQL server by running the command below.

sudo service mysql start
sudo service mysqld start

  • Thanks for the reply MDS. I tried those and got the following:

    sudo service mysql start
    start: Job failed to start

    sudo service mysqld start
    mysqld: unrecognized service

    I restored the site now from backup a couple of other times and MySQL seems to be running at first because the website shows up for a little bit and then all of a sudden just stops working and gives me the Magento error page stating "There has been an error processing your request
    Exception printing is disabled by default for security reasons.

    Error log record number"

    • Check your web server's error log and see if you can find the error. By default it will be in /var/log/apache2/error.log for Apache. And /var/log/ngnix/error.log for Ngnix.

    • start: Job failed to start

      It looks like MySQL is experiencing an error while starting and crashing. Can you post the last few lines of MySQL's error log?

      sudo tail -30 /var/log/mysql.err
      • Thank you MDS and Kamaln7 for your replies. This issue was caused due to some corrupted database files. I didn't realize that there was possibility of the backups created by DigitalOcean having corruption and that I should actually backup my database files on my own.

        This corruption in the database was causing MySQL to crash. Luckily my brother was familiar with recovering database and was able to help me out on this and the site is back up!

        Thanks again for your replies.

Have another answer? Share your knowledge.