Postgres login without password

In order to login to postgres without a password, you need to create a .pgpass file in your home directory. The contents of the file should look similar to:


After creating the file, make sure that the file permissions are 600 or less

chmod 600 ~/.pgpass

After the file is setup, you can login to the database just by executing the following command (or alternatively setup an alias in your bash file to that would execute the command. If you’re applying shortcuts, why not get maximum results):

psql -hlocalhost -Uotheruser other_db

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s