I am using below code to connect MySQL
database in PHP
.
try {
shell_exec("ssh -f -L 3307:127.0.0.1:3306 ronak@server_ip sleep 60 >> logfile");
$this->_conn = $this->dbh = new PDO('mysql:host=127.0.0.1;dbname=my_db', DB_USER, DB_PASS);
$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Couldn't connect to database. Please try again!");
}
I want to direct connect with remote MySQL host. Server is on azure virtual machine. How can I do such a configurations?
I already opened 3306
port in azure portal for MySQL. I don't know how to use it in here without ssh tunnel.
Thanks.