Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
by Guna[ Edit ] 2011-12-19 13:34:59
Hi All,
Sometime you'll find "
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)" issue while you using mysql.
Before you look into this issue, you should know about $PATH variable.
This
$PATH variable holds the list of directories where the executables can be found. When you echo
$PATH variable in terminal it lists the following directories:
[guna@localhost ~]$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/guna/bin
So, when you type "mysql" in the terminal it will search these directories and executes the command. In case it doesn't find given command then
you can see "Command not found.." as output.
the same theory applies in the problem too. When you type "mysql" in the terminal it looks in the "
/usr/bin/" and initiates "mysql" in that directory, that's where the problem occurs. but if you installed LAMP in "opt" directory, then your mysql file can be located in mysql executable file
/opt/lampp/bin/".
So take a backup of mysql file in the "
/usr/bin/" directory and copy the mysql in the "
/opt/lampp/bin/" to "
/usr/bin/". you can do this by using this command:
cp /opt/lampp/bin/mysql /usr/bin/
now if you type "mysql" in terminal it'll start without any problem.