Yesterday I got the error:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
when I ran the command mysql through terminal in Ubuntu 10.10
This error can also be linked to error in phpmyadmin:
Connection for controluser as defined in your configuration failed.
I figured out it was due to mysqld not running. I simply did
sudo /etc/init.d/mysql start
to start mysql daemon. This solved the error.