Organizational Research By

Surprising Reserch Topic

connect to a mysql server over ssh in php using -'php,mysql,ssh'


connect to a mysql server over ssh in php  using -'php,mysql,ssh'

i read one post regarding this topic, i also want to do the same,

i have my database on remote linux machine, and i want to connect using ssh and php funcitons,(i am currently using ssh2 library for that)
i tried using mysql_connect, but it gives me cant access (although i have granted permission)
when i tried using this function:

$connection = ssh2_connect('SERVER IP', 22);

ssh2_auth_password($connection, 'username', 'password');

$tunnel = ssh2_tunnel($connection, 'DESTINATION IP', 3307);

$db = mysqli_connect('127.0.0.1', 'DB_USERNAME', 'DB_PASSWORD',
                         'dbname', 3307, $tunnel)
    or die ('Fail: '.mysql_error());


i got error"mysqli_connect() expects parameter 6 to be string, resource given", can anyone please help me on this
    
asked Sep 7, 2015 by rajesh
0 votes
16 views



Related Hot Questions



Government Jobs Opening


...