Error Solutions

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

A search for references to this error;

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

on Google currently returns over 42,600 results implying how much it gets people disturbed.

For most of the cases, people on whose unix systems is not the mysqlserver will experience this issue. take an example  of those who use xampp etc on linux among other technologies as those that i personally prefer due to the flexibility they offer me and wonderful tools therein included.

While looking on to most solutions that did the trick for most of the articles on the web, i didn’t the simplest that i may offer you today. This works when mysql is unable to locate the path to your mysqld.sock file on your file system by looking from a wrong source than yours is in probably, like i said, if you are using xampp for linux.

The trick to get such fixed is a simple as appending a reference to the true path of that file to your mysql command, something like:

…/bin/./mysql –socket /opt/lampp/var/mysql/mysql.sock -u root -p

For cases whereby one has installed mysql-server, it may not have beeb properly started, restarting it could make the trick

sudo /etc/init.d/mysql restart