Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- PHP SSH and mysql connection
- Hendrik Maeder
June 29, 2005, 9:14 am
rate this thread
tunnel. Although that si possible by setting up the tunnel manually
(with 'ssh -L ...'), I'd like it to be done by PHP itself.
Now, with the SSH2 extension (http://www.php.net/manual/en/ref.ssh2.php )
it is possible to issue a 'ssh2_connect' and then a 'ssh2_tunnel'
That returns a socket resource to the destination server.
So far, all fine.
How can I force that socket onto 'mysql_connect'?
I mean, what I have is:
$tunnel = ssh2_tunnel($connection, '10.0.0.101', 12345);
But $tunnel is a PHP resource, and not in the format ':/path/to/socket'
that mysql_connect expects...
Is this possible at all?
Re: PHP SSH and mysql connection
According to manual mysql_connect() does not expect necessarily a socket
file (actually, ":/path/to/socket" support was added at a later time).
I haven't tried it myself with PHP so it's just a guess but... Once the
tunnel if open, can't you simply connect through it using host+port as
usual? The idea of a tunnel is that applications don't have to know about
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
- » any place I can get a advance search function script written in PHP?
- — Previous thread in » PHP Scripting Forum