the other day i was getting this error message and i wondered why do I get a MySQL "Can't connect to local MySQL server through socket" error?

Answer: This error just means that your script cannot connect to your MySQL database server. Check to make sure your mysqld server is running, if it is, try restaring your server. and if that doesnt work, check to make sure you have the correct hostname on your script. or put the ip address instead of the hostname. the most common hostname used is 'localhost' or '127.0.0.1'

Another problem you might have is that you may have your credentials incorrect. check to make sure you have the username, password, database correct. A customer of mine, changed his password and forgot to change in his configuration file and that's whay he was getting this error.