I have domain and hosing in bigrock linux shared server.
Digital Ocean Managed MySql DB successfully connect via Navicat for Mysql but when i use these credentials in my php project its not working showing error
Basically i am trying to connect Digital Ocean MySQL DB with php project which is hosted on Bigrock shared linux server.
Code i Have Used
<?php
ini_set('display_errors', 1);
$servername = "db-mysql-db.ondigitalocean.com"; // CHANGED FOR SEQURITY
$username = "repo_Jyoti"; // CHANGED FOR SEQURITY
$password = "AVNbJQM"; // CHANGED FOR SEQURITY
$dbname = "repo_Jyoti"; // CHANGED FOR SEQURITY
$port = "27850"; // CHANGED FOR SEQURITY
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
$dsn = 'mysql:host=' . $servername . ';port=' . $port. ';dbname=' . $dbname; // Create a new PDO instanace
try{
$dbh = new PDO($dsn, $username, $password, $options);
echo "Connected successfully";
}
// Catch any errors
catch(PDOException $e){
echo "Connection failed: " . $e->getMessage();
}
?>
ERROR : Connection failed: SQLSTATE[HY000] [2002] Connection refused
if you want to see the errors by yourself please visit
https://wapi.rentdekhoo.com/bbsapi/repo_Offline/testconn.php