0

I have an hosting account with PostgreSQL and PHP. I need to access to an PostgreSQL Database, those Database is only accessible from outside via SSH.

How can I communicate with the PostgreSQL using PHP? What are my best options?

Can someone give me a clue?

Can I use for example something like this? http://realprogrammers.com/how_to/set_up_an_ssh_tunnel_with_putty.html

Best Regards,

1
  • I guess you have your own answer. Creating a tunnel to the server is the best option. That way, you can use a local port as if it was the server itself. Commented Mar 9, 2011 at 9:50

3 Answers 3

1

Once you've set up the tunnel, you connect to your database via 127.0.0.1. e.g. (MySQL Example):

ssh -L 127.0.0.1:3307:127.0.0.1:3306 [email protected]

After that the connection parameters for my database are:

Host: 127.0.0.1 (localhost would try to connect to socket)
Port: 3307
User: DatabaseUser
Pass: DatabasePass
Sign up to request clarification or add additional context in comments.

Comments

0

After setting up the database, you should be able to interact with it using built-in methods that PHP provides:

For reference and tutorials, check out: http://www.php.net/manual/en/book.pgsql.php

Comments

0

You can use putty to ssh into your server and from there you can run postgreSQL, here some help running postgreSQL from a command line: http://www.postgresql.org/docs/8.3/static/app-psql.html

Or you can use a tool like phpmyadmin but to configure postgreSQL called phpPgAdmin: http://phppgadmin.sourceforge.net/doku.php

Hope this helps you a bit :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.