I set the password for the user using the syntax:
postgres=# alter user pavel with password '1'; ALTER ROLE Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- pavel | Create role, Create DB | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig ----------+----------+-------------+----------+---------+--------------+-------------------------------------+----------+----------- postgres | 10 | t | t | t | t | md521.............................. | | pavel | 18066 | t | f | f | f | md58f.............................. | | But when I enter under the role of pavel
$ psql -U pavel postgres My password is not requested.
Why doesn't postgres ask me for a password, although I don't use sudo ? What could be the reasons? (it all works under linux).
pg_hba.conf
# Database administrative login by Unix domain socket local all postgres peer # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. #local replication postgres peer #host replication postgres 127.0.0.1/32 md5 #host replication postgres ::1/128 md5
pg_hba.conf? Maybe there thetrustmethod is registered for your user or host?.pgpassn't there a.pgpassfile in the root of your home directory? - Sergey Gornostaev.pgpassdid not find and inpg_hba.confthere a lot of things added to the question that seemed to me to relate to your question. - Pavel