Postgresql Tips

Connect to a remote postgresql server

In order to connect to a remote postgres server you need to first edit the


set the option listen_address as * or any ip address/hostname you want to login form

listen_addresses = “*”

next you need to set the client authentication settings in


add the following line to login from anywhere or set the specific ip/subnet

host all all md5

Now restart postgresql server and login using the command below

$ psql -h -p 5432 -U postgres -W <databasename>

Other important tips

Create new user

CREATE USER user_name;

Change permissions


Change owner of a database

ALTER DATABASE db_name OWNER TO new_user_name;

Change password of a user

ALTER USER user_name WITH ENCRYPTED PASSWORD ‘new password’;

Like what you read? Give Deepak Kumar a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.