Unable to connect to MySQL Database


#1

Hello,

When I’m trying to connect from to db, I got that error: "Unable to connect: No such file or directory "
That’s my php code:

$connection = new mysqli($server_name,$username,$pass,‘epiz_21828165_nexus’);
if($connection->connect_error){
die("Connect error : " . $connection->connect_error);
}

host, user, pass and db is from “MySql Databases” located in cpanel.
How to resolve that issue?


#2

That error message is listed in the Common MySQL Errors article. Please check that article first to see whether it answers your question.


#3

The $server_name contain the same address that’s shown in the Cpanel


#4

@ama123 said:
The $server_name contain the same address that’s shown in the Cpanel

Well, apparently not, or you wouldn’t get that error.

I took a quick look at your code and I see two functions where you use mysql. The first one is configured properly, the second one tries to login as user root on server localhost without any password. The first one should work, the second one won’t.


closed #5