Home MySQL Socket error on *nix OS

MySQL Socket error on *nix OS

I was having a problem accessing mysql from terminal and get this error.

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

After spending about 30 mins, I found out that the error comes from configuration of MySQL and there is no socket file on the default file location.

To solve this,follow these steps.

#1.look for socket file
$ find /opt/lampp -name "*.sock"

#2.edit the configuration file with your favorite editor
$ sudo gedit /etc/mysql/my.cnf
#3.replace all socket location with the output from previous command.

Now,run mysql command again and it should be working. If the problem is still continuing, please check that the server is running and also make sure about the port and bind-address. Log files(/var/log/mysql/mysql.log & /var/log/mysql/error.log) can give you clues too.

Happy Querying…

This post is licensed under CC BY 4.0 by the author.

Summer,Fahrenheit 451 & Hometown

How to add XFCE custom application launcher