【发布时间】:2023-03-11 00:01:01
【问题描述】:
我在 Windows 的 powershell、命令提示符和 ubuntu 上进行了尝试:
postgres=# CREATE USER sally WITH PASSWORD 'secret';
CREATE ROLE
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
sally | | {}
postgres=# \q
> psql -U sally
Password for user sally:
psql: error: could not connect to server: FATAL: password authentication failed for user "sally"
如果我写 psql 或 $ sudo su - postgres(在 ubuntu 中)
它会询问我的 Windows 用户名(恭敬地):
Password for user xyz:
[sudo] password for xyz:
这是我的pg_hba.conf
...
# local DATABASE USER METHOD [OPTIONS]
# host DATABASE USER ADDRESS METHOD [OPTIONS]
# hostssl DATABASE USER ADDRESS METHOD [OPTIONS]
# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS]
#
...
# TYPE DATABASE USER ADDRESS METHOD
# 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.
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
【问题讨论】:
标签: postgresql powershell command-prompt ubuntu-20.04