You are here: Re: php connect to mysql via ssh « PHP Programming Language « IT news, forums, messages
Re: php connect to mysql via ssh

Posted by ZeldorBlat on 09/12/07 20:23

On Sep 12, 4:00 pm, mtuller <mitul...@gmail.com> wrote:
> I would like to encrypt data passed between my web server and the
> database server. I have looked all over, but don't see any information
> on how to connect to mysql via ssh with php. Is it possible?

You want to use SSH tunneling to do this. Basically, suppose PHP is
running on hostA and MySQL is running on hostB. You then SSH from
hostA to hostB like this:

ssh -L 3306:hostB:3306 hostB

What this says is "From hostA ssh to hostB. When you do that, make
port 3306 on hostA forward everything over to port 3306 on hostB."

Finally you tell PHP to connect to use localhost (hostA) as it's
database server and it should just magically work.

You can even set up the SSH connection on a different machine. So,
from hostC you would do:

ssh -L *:3306:hostB:3306 hostB

And then configure PHP to use hostC as it's database server.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация