postgresql Lion下的PostgreSQL:密码是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7759297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:08:18  来源:igfitidea点击:

PostgreSQL under Lion: What's the password?

macospostgresqlpasswordsosx-lion

提问by matt

I got my new lion machine. Ran the PostgreSQL installer from the PostgreSQL site for Mac and i have no multiple apps installed. One of them is "pgAdmin III.app". When I open it there is already one server connection available. localhost:5432

我得到了我的新狮子机。从 Mac 的 PostgreSQL 站点运行 PostgreSQL 安装程序,但我没有安装多个应用程序。其中之一是“pgAdmin III.app”。当我打开它时,已经有一个服务器连接可用。本地主机:5432

Whenever I try to connect to the server with a doubleclick the programm asks me for a password. I have no idea what to enter. It's not my admin password, it's not "postgres", it's not "localhost", it's not empty.

每当我尝试通过双击连接到服务器时,程序都会要求我输入密码。我不知道该输入什么。这不是我的管理员密码,不是“postgres”,不是“localhost”,不是空的。

I just can't seem to connect to the server. Even when I check the properties of the localhost server the password field seems empty. However I'm not allowed to leave the password field empty.

我似乎无法连接到服务器。即使当我检查本地主机服务器的属性时,密码字段也似乎是空的。但是我不允许将密码字段留空。

Any idea what to do? I really need to setup postgres?

知道该怎么做吗?我真的需要设置 postgres 吗?

采纳答案by tscho

Haven't tried it on OSX, but on Ubuntu you can login as the system user 'postgres' to the default database 'postgres' without a password with

尚未在 OSX 上尝试过,但在 Ubuntu 上,您可以以系统用户“postgres”的身份登录到默认数据库“postgres”,无需密码

su postgres -c psql

You can then (re)set the password of the database superuser 'postgres'.

然后,您可以(重新)设置数据库超级用户“postgres”的密码。

You can also edit the configuration file pg_hba.conf(don't know where it is located on a default OSX installation, on Ubuntu it is /etc/postgresql/8.4/main/pg_hba.conf) and grant access to the default database without authentication

您还可以编辑配置文件pg_hba.conf(不知道它在默认 OSX 安装中的位置,在 Ubuntu 上是/etc/postgresql/8.4/main/pg_hba.conf)并授予对默认数据库的访问权限而无需身份验证

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
host    postgres    postgres    127.0.0.1/32          trust

After editing pg_hba.conf you must reload the configuration with

编辑 pg_hba.conf 后,您必须重新加载配置

pg_ctlcluster 8.4 main reload

You can then connect with pgAdmin and (re)set the password, but don't forget to change the authentication method back to md5again...

然后您可以使用 pgAdmin 连接并(重新)设置密码,但不要忘记md5再次将身份验证方法更改回...

回答by ssc

On my Mac OSX Lion, PostgreSQL configuration files are stored under /Library/PostgreSQL/9.0/data/

在我的 Mac OSX Lion 上,PostgreSQL 配置文件存储在 /Library/PostgreSQL/9.0/data/

回答by ekkis

here's a better answer (works in OSX HighSierra): the account used is the one you're logged onto OSX with, therefore, the password is your password!

这是一个更好的答案(适用于 OSX HighSierra):所使用的帐户是您登录 OSX 时使用的帐户,因此,密码就是您的密码!

回答by A.H.

A similar question has been asked a short time ago. The steps described there should be appropriate for Lion also.

不久前也有人问过类似的问题。那里描述的步骤也应该适用于 Lion。

Postgresql: password authentication failed for user "postgres"

Postgresql:用户“postgres”的密码认证失败