Monday, 5 September 2011

Solving MySQL Connection Error In Non-standard Bundles

For a standard MySQL installation from software repository, there won't be much problem in using MySQL for different connections however if you install some other bundles such as LAMPP, you are most likely to see an error Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' however the solution to this is as easy as making a symbolic link of MySQL socket.

In my case, I had LAMPP installed and the MySQL socket was in the folder /opt/lampp/var/mysql/mysql.sock and your might be different so first figure out the location of this MySQL socket and then just enter the following commands and you're done.

samar@Techgaun:~$ sudo mkdir /var/run/mysqld/
samar@Techgaun:~$ sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

That should work as a charm. I hope this helps :)