I was working on Ubuntu 14.04 64bit server, where I installed Mysql server and hosted database application to run on it.
One day I tried to reset root password of my Cloud Virtual Server, when I reset the root password of the server, suddenly after reboot, MySQL stopped working.
I was getting error like "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
This means that Mysql was unable to start because there were files missing in /run/mysqld
|/run/mysqld socket files|
I somehow I wanted to create these two files again so that I can resolve this issue.
Reinstalling of mysql server was not an option as I was unaware about the database files which were already there in server.
So to resolve this issue I followed below steps and the Issue was resolved.
1) Try to run this command
ps -A|grep mysqlThis will show you mysql process running and we have to kill that process.
2) Now kill the running mysql process, use this command
sudo pkill mysqlThis will kill mysql process.
3) Now kill the mysqld process
ps -A|grep mysqld
sudo pkill mysqld
4) Now you are ready to restart your mysql services as already running mysql processes are killed.
sudo service mysql restartOnce your mysql service is restarted , you can see that those missing files are created at /run/mysqld .
Now you will not get the error message "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock" as socket files are created successfully.
Hope this tutorial helps you in resolving issue of mysql connection throug socket.
To improve this article you can comment below with your views.
Thanks for reading.