Postgres Configuration
To enable other computers to connect to your PostgreSQL server, edit the file /etc/postgresql/9.5/main/postgresql.conf
Locate the line #listen_addresses = 'localhost' and change it to:
listen_addresses = '*'
You can run the following SQL command at the psql prompt to configure the password for the user postgres.
ALTER USER postgres with encrypted password 'your_password';
After configuring the password, edit the file /etc/postgresql/9.5/main/pg_hba.conf to use MD5 authentication with the postgres user:
local all postgres md5
Finally, you should restart the PostgreSQL service to initialize the new configuration. From a terminal prompt enter the following to restart PostgreSQL:
sudo systemctl restart postgresql.service
User configuration link
Add Linux User
# adduser tom
# passwd tom
Add Postgres User
su - postgres
CREATE USER tom WITH PASSWORD 'myPassword';
Create Empty Database
CREATE DATABASE jerry;
Give Permissions of new user
GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
Test user permissions on database
psql -d jerry -U tom