MYSQL -- Error 2002, Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I hit this error during my ERPNEXT installation process.
Where the MySQL was came with LAMPP installation
thus the mysql.sock is located in ../lampp/var/mysql/mysql.sock

I googled and found this, mysql-install-db-problems as my solution.

The steps :
1. set the environment variable to LAMPP mysql.sock path
    $ export MYSQL_UNIX_SOCK='/opt/lampp/var/mysql/mysql.sock'
    *) the path may vary make sure you do below steps to get the right path
        or location:
        $ sudo updatedb
        $ locate mysql.sock
2. Re-install the MySQLdb

Edit:
I had this same problem in fedora 19 64bit and the yum reinstall just didn't work.
So i tried to make a symbolic link to LAMPP mysql.sock and turns out work like charm.

# ln -s /opt/lampp/var/mysql/mysql.lock /var/lib/mysql/mysql.sock

Hope it helps and happy coding!

Comments