postgres生成与os用户名匹配的用户的密码是什么?

时间:2019-04-02 03:30:44

标签: postgresql

我是Postgres的新手。

Postgres在安装时会产生两个用户,一个是'postgres',另一个与您的os用户名匹配。

Getting Started with PostgreSQL on Mac OSX #3-configuring-postgres

  

我们看到了我提到的Postgres用户,但是那个其他用户,engineerpart是什么?这是Postgres首次安装时使您的生活更加轻松的事情之一...因此,在安装Postgres时,它将自动创建一个与您的用户名匹配的数据库用户,以便您可以立即开始使用。

但是与os用户名匹配的用户密码是什么?

我的操作系统用户名是'zhouhancheng',我经常遇到以下错误:

failed: FATAL:  password authentication failed for user "zhouhancheng"

macos:10.13 PostgreSQL:11.2

1 个答案:

答案 0 :(得分:0)

从10.6版开始,PostgreSQL默认不会为os用户名创建密码。
检查您的pg_hba.conf并允许无密码访问。
您可以使用以下设置允许从本地主机进行无密码访问。

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust  

或者,当您使用initdb初始化数据库集群时,可以为os用户名指定密码。

-W
--pwprompt
Makes initdb prompt for a password to give the database superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.

(不过您认为initdb是由brew执行的)

相关问题