To prevent "MySQL Error 2002 Can't connect to local MySQL server through socket", we have to follow those steps.
I tried the following steps:
- Log in as super user or use sudo
- Open /etc/mysql/my.cnf using gedit
- Find bind-address and change its value to the the database server host machine ip. For me, it was localhost or 127.0.0.1
- Save and close the file.
- Come back to terminal and execute sudo service MySQL start
General case it's problem of my.cnf.
If you didn't find solution you can try this option as well
sudo apt-get install mysql-server
execute above comment in terminal, after you found MySQL-server installation is process.
completation of whole installation process restart your server.
sudo service mysql start
You found the solution of your problem