Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- }
- Error!: SQLSTATE[HY000] [1130] Host 'host' is not allowed to connect to this MySQL server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement