I am trying to access remote MySQL server by its IP using PHP.
Here is my code:
$servername = "100.XXX.XXX.XXX:3306"; // MySQL IP
$username = "root";
$password = "Password012";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else {
echo "success";
}
This is working fine on my local machine but not on live.
I am getting this error:
Warning: mysqli::mysqli(): (HY000/2002): Connection refused in [...]
Any suggestions?