View Single Post
Veteran Member
Join Date: Apr 2010
Old 11-23-2012 , 14:06   Re: Frequently Asked Questions (FAQ)

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:
  1. Locate the mysql config file (usually located in /etc/mysql/, called 'my.cnf').
  2. Edit the file with a text editor and search for the string "socket = /var/run/mysqld/mysqld.sock".
  3. If socket is pointing towards something different, please change the string to the above and save your config file.
  4. Restart the mysql server (/etc/init.d/mysql restart).
  5. 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 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!
Mavrick4283 is offline