Here is the gist of my problem: I have a web application that won't connect when the database has the host is set as localhost, however it will if I use the address 127.0.0.1. The error that PHP gives me when connecting is: "SQLSTATE[HY000][2002] Permission denied". I know that the socket is there because when I stop the service I get "SQ:STATE[HY000][2002] No such file or directory."
After I type in "ls -als /tmp" in the terminal, I see that mysql.sock has the permissions of 777.
Any ideas why I cannot connect to the socket?
Best Answer
Does your
mysql.user
table have an entry for your database user forlocalhost
host? If not, that is the reason forPermission denied
error from MySQL.