Videos / Other Resources

No attachments were found.

Run PostgreSQL Over a Network

Overview:

  • I want to use a second computer for poker and share a PostgreSQL database over my local area network.

 

  • I want to use the database on my home computer over the internet when I'm traveling.  (Complete Steps 6 and 7 for this.)

 

Note: This should only be attempted if you're comfortable doing advanced networking tasks with a computer. It's also your own responsibility to backup and protect your own data and computer.

 

 


Walkthrough:

(Again, only attempt this if your computer networking skills are advanced.)

 

  1. Make sure your PostgreSQL password is secure.

To change your password in pgAdmin, do the following:

a) Launch PgAmdin3.exe in the C: Program Files/PostgreSQL/8.3/bin directory.

 postgresql-network-01.jpg

 
b) Go to loginrole.
c) Right click on the user postgres and choose Properties.
d) Change the password and choose OK.

2.  Make sure your computer with the database on it (the database server) has a static IP address. For the sake of this article, we assume it is 192.168.2.2.

3.  Allow PostgreSQL to have a login from other machines.

Change the postgressql.conf file:

Go to C:\Program Files\PostgreSQL\8.x\data, move the postgressql.conf file to your Desktop and open it with notepad. 

Make sure that by listen_adress a * is filled.
Save it and move the file back to the data folder.
Restart the PostgreSQL service: Control Panel -> Administrative Tools -> Services

Change the pg_hba.conf file likewise. Go to C:\Program Files\PostgreSQL\8.x\data, move the pg_hba.conf file to your Desktop and open it with notepad. 

Add a line like host/all/postgres/0.0.0.0/md5 if you want to access your database from the internet (See also additional steps for Internet access)

Or add a line like host/all/postgres/192.168.2.3 (= Ip-adres laptop)/md5 if you only want to access your database from inside your local network with your laptop/ second computer.

Or add a line like host/all/postgres/192.168.2.0 (= address of your local network)/md5 if your laptop is getting an IP Adres from a DHCP server within your network.

Or add a line like host/all/192.168.2.3/trust if you do not want have anything to do with passwords.

Save it and move the file back to the data folder.
Restart the PostgreSQL service: Control Panel -> Administrative Tools -> Services

 

4.  Make a firewall exception

Go to Windows Firewall (if your use another firewall; please look how to set-up an port exception in the manual)

Go to Change setting and Choose Add Port.

 postgresql-network-04.jpg

 

 

Name: Postgres
Port number : 5432
TCP
And choose: Change scope

 postgresql-network-05.jpg

 

 

 

Choose: Any computer if you want to access your database also form the internet
Or choose My Network in you want to access your db only from your local network.

 

 postgresql-network-06.jpg


5. Access your HM database from your laptop:

Install HEM on your laptop.
You do NOT need to install Postgres on your laptop.

Open HEM on your laptop.

Fill in the connection to your database server 192.168.2.2

 

postgresql-network-07.jpg 


(If already configured HEM; choose database management in Options to change the settings)
Login name is postgres; password is the password you have set-up in step 1.

Connecting should connect you to the database server.

Additional steps to access your database via the internet.

 


6. - Make a free DynDNS account and host.

Make sure your router/internet modem supports DynDNS. Go to http://www.dyndns.org. Make a free account.
Set-up a host service for example: MyHEMDBserver.dnsalias.org

Set-up your router to update your DynDNS record. (This depends on your router; please look into you manual)
And /or use the free downloadable program DynDNSUpdater to be found: http://www.dyndns.com/support/clients/ for update your DynDNS record.
Make sure your DNS record on DynDNS is updated regularly otherwise your account will expire.

 

 

7.  Set-up your router to redirect access from your router to your database server.

Make a portforward for TCP port 5432 towards the ip address of your databaseserver:
postgresql-network-08.jpg


How you do this depends on your router. Help can be found on http://portforward.com/

 

 

8 – Accessing your database form the internet.

Start-up HEM.
Open HEM on your laptop.
Fill in the connection to your database server MyHEMDBserver.dnsalias.org on your laptop.

 postgresql-network-09.jpg

(If already configured HEM; choose database management in Options to change the settings)
Login name is postgres; password is the password you have set-up in step 1.
Connecting should connect you to the database server at home.

pgadmin-02.jpg

 

 

 

 

 

| More

Related Articles


User Opinions (8 votes)

100% thumbs up 0% thumbs down

How would you rate this answer?



Thank you for rating this answer.

Visitor Comments

No visitor comments posted. Post a comment

Post a comment

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.
   Name:
   Email:
* Comment:
* Enter the code below:
 

Continue