I've just had this error on my server.
I had a script running fine in a website of this server and tried to change it to another site in this same server.
When I moved files I host this error:
Can't connect to local MySQL server through socket
Everything appeared to be okay but it didn't work.
I've just changed the host to connect from "localhost" to "localhost.localdomain" and it worked perfectly fine.
If you had this error maybe it could work for you! :-)
Also restarted mysql.
Best wishes,
NarcĂs