Tools
Configure access to an embedded PostreSQL database from multiple hosts
By default, PostgreSQL does not allow external connections. This article describes how to configure embedded PostgreSQL in Microsoft® Windows®, Linux, and a Virtual Appliance to allow connections from a machine other than the PostgreSQL server.
First published date
Last published date
Overview
PostgreSQL does not allow external connections, by default. This article describes how to configure embedded PostgreSQL in Microsoft® Windows®, Linux, and a Virtual Appliance to allow connections from a machine other than the PostgreSQL server itself.
Product section
Resolution
Linux/CentOS (Virtual Appliance)
- Connect to the virtual appliance VA using an SSH client (such as PuTTY).
- Enter
adminin the user name and password fields to log in. - Change directories to
/data1.
The Linux path is:
/usr/local/webhelpdesk/bin/pgsql/var/lib/pgsql/9.2/data
Command: cd /data1 - Use the 'sudo' command to edit the config files with Vi editor. Make a copy of the original file before editing.
sudo cp pgdata/postgresql.conf pgdata/postgresql.conf.original.Command:
sudo vi pgdata/postgresql.conf.
- In the connections and authentication section, uncomment
listen_addressesand set to:
listen_addresses = '*' - Save your changes.
Type:wand press Enter. - Exit vi.
Type:qand press Enter. -
Edit the
pg_hba.conffile. Make a copy of the original file before editing.
Type:sudo cp pgdata/pg_hba.conf pgdata/pg_hba.conf.original.
sudo vi pgdata/pg_hba.conf.
Thepg_hba.conffile should contain following lines:local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all whd 0.0.0.0/0 md5 -
Add a line with
your_ip. your_ipthat represents the IP address of the host from which you want to connect with pg Admin.
For example,local all all trust
host all all 127.0.0.1/32 trust
host all all your_ip/32 trust
host all all ::1/128 trust
host all whd 0.0.0.0/0 md5 -
Restart WHD.
-
Change to the WHD directory.
Type:
cd /usr/local/webhelpdesk -
Stop Web Help Desk.
Type:
./whd stop -
Start Web Help Desk.
Type:
./whd start
-
Microsoft Windows
- Log in to the Web Help Desk server as an administrator.
- Navigate to
<WebHelpDesk>\pgsql9\data. - Back up the following files to a separate location:
-postgresql.conf
-pg_hba.conf - Open the
postgresql.conffile in a text editor (such as Notepad). - In the connections and authenticationsection, uncomment
listen_addressesand set the parameter to:listen_addresses = '*' - Save your changes.
- Open the
pg_hbafile in a text editor. - Locate the following lines:
# IPv4 local connections:
host all all 127.0.0.1/32 password
# IPv6 local connections:
host all all ::1/128 password - Add a line with
your_ip. your_ipthat represents the ip address from which you want to connect with pg Admin.
For example,
# IPv4 local connections:
host all all 127.0.0.1/32 password
host all all your_IP/32 password - Click Save.
- Stop WHD using the Start Menu options (right-click and select Run as Admin).
- Stop PostgreSQL service under services.msc.
- Start PostgreSQL service under services.msc.
- Start WHD using the Start Menu options (right-click and select Run as Admin).