I installed LAMP on Ubuntu 12.04 LTS (Precise Pangolin) and then set root password on phpMyAdmin. I forgot the password and now I am unable to login. When I try to change password through terminal I get:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
How can I fix this? I am unable to open LAMP, uninstall it or reinstall it.
Best Solution
I once had this problem and solved it by installing
mysql-server, so make sure that you have installed themysql-server, not themysql-clientor something else.That error means the file
/var/run/mysqld/mysqld.sockdoesn't exists, if you didn't installmysql-server, then the file would not exist. So in that case, install it withBut if the
mysql-serveris already installed and is running, then you need to check the config files.The config files are:
In
/etc/my.cnf, the socket file config may be/tmp/mysql.sockand in/etc/mysql/my.cnfthe socket file config may be/var/run/mysqld/mysqld.sock. So, remove or rename/etc/mysql/my.cnf, let mysql use/etc/my.cnf, then the problem may solved.