Couldn't connect to serverSQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")Please try again later.
That is the message I’m getting. I have checked the dbname, username and password. Can anybody share any ideas?
php.ini is a file just like any other. If you arnt in control of the box in question, you should contact your host to find out why their box is not configured for mysql.sock.
Thanks again. I have about 2 accounts on the same server. Php is running fine on one of them but not this one. Do you think it could be a minor code error?
This is what I got as response from the host, not sure what to do with it. I’ve been asked by one person here to change stuff in the PHP.ini file but my host doesn’t allow for it.
Hi,
The default location for the Unix socket file that the server uses for communication with local clients is /tmp/mysql.sock.
$pdo = new PDO ('mysql:unix_socket=/tmp/mysql.sock; dbname=realdb','username','password');
Cautionary warning that your local environment will probably not work with that. So you will need to change out the connection credentials per environment.
On changing that I get the same error with the updated socket name.
Couldn’t connect to serverSQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2 “No such file or directory”)
I’ve uploaded the exact same files to another domain I have registered with those guys and it’s working. Just not on this domain. I ask them that and they say they do not know and that it is something I should figure.