I am trying to connect to MySQL on a LAMP instance. If I run
$mysqli = new mysqli("localhost", "user", "pass");
if ($mysqli->connect_errno) {
die("Connection error: " . $mysqli->connect_error);
}
I only receive the connection error
No such file or directory.
This is the information I get from phpinfo():
When I try changing localhost
to 127.0.0.1
or if I add the port as follows localhost:3306
or 127.0.0.1:3306
the error changes to 'Connection refused'. The LAMP instance is running on a remote server by my company where I do not have any root access. Do you have an idea what I could do to fix the MySQL connection?
EDIT: This question is not the same as for example this question since I do not have root access on the server where the MySQL instance is on. Therefore I cannot use the regular tricks to check whether mysql.sock
is in the right place etc. I am pretty sure that the server's settings are correct, I just need help finding out how to write my MySQL-connection correctly.