Sources: http://www.stuartellis.name/articles/postgresql-setup/, http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/
On ubuntu:
#Authentication Management:
sudo -u postgres psql #This works only when pg_hba.conf is configured with value 'peer' for key 'method' for user 'postgres'.
postgres=#ALTER ROLE postgres WITH ENCRYPTED PASSWORD '<PASSWORD>'
OR,
postgres=#\password #This also updates password for current/(supplied user name) securely.. RECOMMENDED.
postgres=#\q
#Update: /etc/postgresql/9.3/main/postgresql.conf
listen_addresses = '*'
#Update: /etc/postgresql/9.3/main/pg_hba.conf
local all postgres md5 #To be changed from peer to md5
host all all 192.168.56.0/78 md5
sudo /etc/init.d/postgresql restart
#psql shell commands
postgres=#\? #Lists all commands and description..
postgres=#\list #Lists databases in .
postgres=#\dt[S+] #Lists all tables.
postgres=#create user <USER_NAME> with encrypted password '<PASSWORD>';
postgres=#grant all privileges on database <DB1,DB2..> to <USER_NAME>;
postgres=#\q #To quit psql
postgres=#psql -U <USER_NAME> -d <ALLOWED_DATABASE_NAME> -hlocalhost;
postgres=#CREATE DATABASE "<NEW_NAME>" TEMPLATE "<EXISTING_NAME>"
Prob#1:-forgot 'postgres' password https://support.plesk.com/hc/en-us/articles/213397149-How-to-reset-password-for-PostgreSQL-user-postgres-
Soln: 1>Update pg_hba.conf setting value 'peer' for 'method' against user 'postgres',
2>Restart postgres
3>Follow steps above for Authentication management.