Solved: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

June 28, 2015   /   by Marco  / Categories :  Technology

My VPS server experienced an issue with mySQL server and thought I’d better document how to resolve it in case it happens again.

The symptoms

  • An Error message saying unable to connect to the database comes up when trying to access websites using WordPress
  • Manually starting the mysqld came back with “Failed”- using the command
service mysqld restart
  • Rebooting didn’t fix the problem
  • When trying to run “mysql” an error message came back with
    Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

The solution

For some reason this worked for me – it may not work for you.  All you have to do is run the database in recovery mode so follow these instructions:

SSH into your VPS server

Edit the my.cnf file in the folder /etc and add the following line:

innodb_force_recovery = 1

Then save the file

Restart mysqld by using the following command:

service mysqld restart

It should now work. If the server started with OK then it worked.

Go back and disable the innodb recovery by either removing the line or just adding a # at the front.

Hopefully this has fixed your issue.

Cant connect to local MySQL server through socket

RESOURCES
Here’s a list of resources that you might find useful:

More information about innodb force recovery: Click here

 

 

DO YOU LIKE WHAT YOU'VE READ?
Join our subscription list and receive our content right in your mailbox. If you like to receive some Great deals our Freebies then subscribe now!

Our Sponsors

  • Follow us:

OTHER ARTICLES YOU MAY LIKE


STOP NOISY CALLS: THE ANDROID SETTING YOU SHOULD SWITCH ON TODAY

STOP NOISY CALLS: THE ANDROID SETTING YOU SHOULD SWITCH ON TODAY

Phone calls still matter. Whether you’re speaking to a client, checking in with family, or handling something urgent on the move, clarity can make or break the conversation. If you’ve ever found yourself apologising for the construction noise behind you, the wind across your microphone, or the café chatter muddling your words, there’s an Android […]

read more
FILMORA 15 – WHAT’S NEW? AI EXTEND, DYNAMIC CAPTIONS, TRUE TIMELINE EDITING + INSTALL GUIDE

FILMORA 15 – WHAT’S NEW? AI EXTEND, DYNAMIC CAPTIONS, TRUE TIMELINE EDITING + INSTALL GUIDE

There is a particular thrill to installing a major new release of your everyday editor, especially when your workflow is comfortable and productive in the current version. That feeling is right at the heart of the move from Filmora 14 to Filmora 15. This upgrade promises fresh creative features, faster handling of complex projects, and […]

read more

Like our Page