Q: I'm getting the following error: "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'".
A: This means that the mysql server you have installed doesn't seem to run or isn't placing the mysql socket file in the correct location.
On a linux machine you can do the following:
- Locate the mysql config file (usually located in /etc/mysql/, called 'my.cnf').
- Edit the file with a text editor and search for the string "socket = /var/run/mysqld/mysqld.sock".
- If socket is pointing towards something different, please change the string to the above and save your config file.
- Restart the mysql server (/etc/init.d/mysql restart).
- Browse to the /var/run/mysqld/ directory and do a directory listing (ls) to see if the mysqld.sock file is placed there!
A different, but less likely situation, could be that the socket file is placed there but the server itself can't connect to the localhost. Instead of using localhost as mysqlserver address, revert back to the ip 127.0.0.1 or simply use the ip address that the machine has been given if it is directly connected to the internet.
Also check to make sure that the machine isn't running a firewall (which would commonly be called 'iptables' on a linux machine) and blocks any incoming traffic to port 3306 (default sql port). You can do a listing with 'iptables -L -n'. Remember you can only edit the iptables settings if you are using 'sudo' or 'root' itself!