Adding user Without password in postgres

Viewed 2161

I have installed Postgres v12 on Windows Machine. I have looked documentation of Postgres, but they are using command-line tools commands as

create user <username> etc,

I am using these commands but didn't get Logged into it.It says

fe_sendauth: no password supplied

Sql Shell

How Can I add a user in Postgres psql shell without a password ?

1 Answers

If you don't want to be prompted for a password, you will need to have provision for that user in your pg_hba.conf file.

For example:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

host    all             user1           0.0.0.0/0               trust
host    all             all             127.0.0.1/32            md5

The first line beginning with "host" uses the method of "trust" which means the user will go unchallenged. You can change any of the other parameters as you see fit, but as long as they hit this rule first, other rules won't insist on a password. Once you make this change, you'll need to reload the service for it to take effect.

Related