Installing PostgreSql

joel
1 min readApr 4, 2019

install postgresql:

enable remote access to PostgreSQL server

  1. Connect to the PostgreSQL server via SSH.
  2. Get location of postgresql.conf file by executing command (it should be something like /var/lib/pgsql/data/postgresql.conf):

# find / -name “postgresql.conf”

3. Open postgresql.conf file and add the following line to the end:

listen_addresses = ‘*’

4. Add the following line to the end of /var/lib/pgsql/data/pg_hba.conf file:

host all all 203.0.113.2/32 md5

  • 203.0.113.2/32 is the remote IP from which connection is allowed. If you want to allow connection from any IP specify 0.0.0.0/0 .
  • md5 is the authentication method, which requires the client to supply a double-MD5-hashed password for authentication.
  • Note: In the above configuration user john.doe from database example1 has access to database example2 and vice versa. To allow user john.doe remotely connect to example1 database only, specify directives as following in the end of /var/lib/pgsql/data/pg_hba.conffile:
    host samerole all 203.0.113.2/32 md5
  • As for other authentication methods refer to PostgreSQL documentation.

5. Restart PostgreSQL server to apply the changes:

# service postgresql restart

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response