Mysql – Can’t connect to local MySQL server through socket /var/run/thesqld/thesqld.sock

MySQL

I have run into this error with a MySQL database installed on lucid lynx 10.04 that was working fine. The last activity carried out before this problem manifested was exporting a database back up using phpmyadmin. Now any attempt to connect results in this error whether from the command line, phpmyadmin tool or php script.

Most of the answers to similar posted questions involve finding where the mysqld.sock file is created and modifying the my.cnf file to point to its locaion. However I cannot see where the mysqld.sock file is created.

I have verified that mysql is running as a service and following one forum advice, typing
ps -fea | grep mysqld results in the following:

rich      10796 8900 0 08:13 pts/1 00:00:00 grep --color=auto mysqld

mysqld is shown in red. The rest of the advice given is to use the above output line to locate the file and modify the my.cnf file accordingly. However I do not know how to interpret the above information to this effect – being a noobie to ubuntu I am in the unhappy position of usually not understanding what the purpose of command lines (often suggested without an explanation) is and what their results should be so am reduced to randomly typing them in from various similar forum questions in the hope that eventually one will have the desired effect without breaking the whole thing in the process.

Could anyone advise a step by step trouble-shooting guide to this problem? Where should the file be ceated in Ubuntu? The path in the /etc/mysql/my.cnf file is /var/run/mysqld/myslqd.sock. I presume this must have been where the file was being created previously when it was working unless the my.cnf file has been changed by some sort of automatic update, which I wouldn't have thought so given a password is usually required in ubuntu before such changes are made.

Thanks
Richard

Best Answer

Try out the below steps .,

backup the my.cnf.,

change the socket location to different location .,.

restart the mysql with #/etc/init.d/mysql restart

try to connect with new socket .