Enable postgresql passwordless login
In this tutorial I will show you how to enable postgresql passwordless login for any postgresql whether it is local postgresql server or it is remote postgresql server. After passwordless login you don’t need to type password again and again.
Step 1. Open the .pgpass file with your favourite editor. pgpass file will be in your home directory.
vim ~/.pgpass
See Also: How to install postgresql 9.6 on centos 7
Step 2. Enter the credentials of your postgresql server in the file as per following format.
hostname:port:database:username:password
I will try to login into postgresql server on my localhost.
[root@installvirtual ~]# psql -U postgres -h localhost
Password for user postgres:
psql (9.6.4)
Type "help" for help.
postgres=#
It is asking for password. Now, I will add details of my postgresql server that is installed on my localhost. Username and password of my postgresql server is postgres.
localhost:5432:postgres:postgres:postgres
Read Also: Install postgresql 9.6 on mac
Step 3. Change the file permissions
chmod 0600 ~/.pgpass
Let’s try to login.
[root@installvirtual ~]# psql -U postgres -h localhost
psql (9.6.4)
Type "help" for help.
postgres=#
You can see i am able to login with the password. You can add a password of any remote server also.
If there are any issues in setting up of password less login please feel free to comment below.
Video Tutorial
Read Also: How to install postgresql on Ubuntu 16.04