right now i am creating a ssh tunnel, so i can connect to my remote database, but for some reason the connection is still refusing... my script:
try {
$host = 'remote host';
$sshuser = 'ssh user';
$sshpass = 'ssh password';
$dbuser = 'db user';
$dbpass = 'db user';
$dbname = 'db name';
shell_exec("ssh -p$sshpass ssh -o StrictHostKeyChecking=no -f -L 3307:127.0.0.1:3306 $sshuser@$host");
$dbh = new PDO('mysql:host=127.0.0.1;port=3307;dbname=' .$dbname. '', $dbuser, $dbpass);
$sth = $dbh->prepare("SELECT * from table");
$sth->execute();
$result = $sth->fetchAll();
print_r ($result);
shell_exec("kill $(ssh-pid)");
$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
And as a result i get:
Error!: SQLSTATE[HY000] [1130] Host 'host' is not allowed to connect to this MySQL server