Can’t connect to local MySQL server through socket…error.
I recently moved my /home folder to its own partition, but in doing so, I broke MySQL. The full error I got was:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
To fix this you need to create the file and make sure that MySQL has access to it. (All commands need to be run as root)
Create the directory (if it doesn’t already exist).
sudo mkdir /var/run/mysqld/
Create the file by “touching” it.
sudo touch /var/run/mysqld/mysqld.sock
Set the ownership of the mysqld.sock file and folder to mysql.
sudo chown -R mysql /var/run/mysqld/
You can then start MySQL and breath easier.