Remote MySQL through SSH Tunneling

I need to make a remote MySQL connection between servers where the hosts have blocked port 3306. I'm thinking port forwarding/SSH tunneling might help me out in this situation, but I haven't found a good example of how to accomplish this with scripting. Most examples focus on doing this between the firewalled server and a workstation client...I need to connect between web servers in a web scripting application.

This seems to describe how you'd accomplish this through the command line, but I need to set this up in such a way that it creates a MySQL resource link equivalent to the mysql_connect() PHP function for use in PHP scripts. Any ideas?

You can specify the port in mysql_connect(). Is there a good way to use port forwarding to get MySQL to listen on some other port on the server (as in non-client) box? I'm not particularly concerned about security (this isn't sensitive data), though I wouldn't be thrilled if someone got my database password. I'd definitely be limiting priviledges with the remote user. mysql_pconnect() might reduce the number of times that stuff gets thrown around.

 

 

 

 

Top