Hi! It’s been a long time since my last post. Why I wrote this? It’s because I got this error last night and it annoyed me so much. Well, I’ve ever got the same error, several months ago.
Alright, the error is kind like this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
We could find that error from PHP error notice or from Terminal when we try to open MySQL connection.
After some hours of Googling, and have no result, I tried my own way. I took it from several sources. And here’s how:
You have to use your root
access
Change the directory to /var/run/mysqld
cd /var/run/mysqld
Create an empty mysqld.sock
file
touch mysqld.sock
Give executable permission to sock file
chmod +x mysqld.sock
Change permission to mysql
user
chown mysql:mysql -R *
Change the working directory to /tmp
cd /tmp
Create a symlink to the sock file
ln -s /var/run/mysqld/mysqld.sock mysqld.sock
And at last, run the MySQL /etc/init.d/mysql
start.
Yeah, my db is up now. :)