Md.shahidul islam
Md.shahidul islam

Reputation: 11

Connecting from localhost to cloud database I get this error

When I connect from localhost I get this error

Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\vici\index.php on line 9 Connection failed: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

here is my code

$servername = "27.111.132.11";
$username = "root";
$password = "123";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

Upvotes: 0

Views: 635

Answers (1)

MySQL connection driver does not get any meaningful server at the location of localhost. So use,

'hostname' => '127.0.0.1'

rather than

'hostname' => 'localhost'

Upvotes: 0

Related Questions