Can’t connect to local MySQL server through socket – Ubuntu xampp and MySql

Sunday, 30. October 2011

If you have come across this problem while connect to MySQL (possibly via command line tool) this solution may work for you. Th issue is mainly because the script is looking for a file – mysqld.sock – in order to be able to connect as localhost but in the wrong location.

MySQL Conenction Error

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Solution
On your terminal run the following two commands

sudo mkdir /var/run/mysqld/

Next run this

sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

Now try again to connect to MySql using your configured MySQL username and password

mysql -u[username] -p[password]

Leave a Reply

You must be logged in to post a comment.