Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding user Without password in postgres

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 ?

like image 264
Anupam Haldkar Avatar asked Sep 05 '26 02:09

Anupam Haldkar


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.

like image 195
Thom Brown Avatar answered Sep 07 '26 16:09

Thom Brown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!