我的用户在 postgresql 中的默认密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23769579/
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-10-21 01:27:34  来源:igfitidea点击:

Default password for my user in postgresql

postgresqlhomebrew

提问by Hugo

I installed postgresql on my Mac through homebrew. It said it didn't create a postgres account, but is using an account with my username instead. However, running the command psqlfails because when I type in my password, it says it's wrong. I've retried it to make sure I'm not typing it wrong. So what's the password it gave me?

我通过自制软件在我的 Mac 上安装了 postgresql。它说它没有创建一个 postgres 帐户,而是使用一个带有我用户名的帐户。但是,运行命令psql失败,因为当我输入密码时,它说这是错误的。我已经重试了,以确保我没有打错。那么它给我的密码是什么?

回答by Peter Headland

There are two different "accounts" here:

这里有两个不同的“帐户”:

  1. The OS X user that owns the PostgreSQL files and processes. When you installed PostgreSQL, you used your own user account for that.

  2. The PostgreSQL user that can log in to the PostgreSQL database. By default, that user is internal to your PostgreSQL instance and has nothing to do with any OS X user.

  1. 拥有 PostgreSQL 文件和进程的 OS X 用户。当您安装 PostgreSQL 时,您为此使用了自己的用户帐户。

  2. 可以登录PostgreSQL数据库的PostgreSQL用户。默认情况下,该用户在您的 PostgreSQL 实例内部,与任何 OS X 用户无关。

For psql, you need #2. Immediately after installation, there should be a user named "postgres" with no password that has full administrative privileges - try logging in with those credentials (and change the password to something secure ASAP).

对于 psql,您需要 #2。安装后,应该立即有一个名为“postgres”的用户,该用户没有密码且具有完全管理权限 - 尝试使用这些凭据登录(并尽快将密码更改为安全的密码)。

回答by David Moles

As per tadman's comment, Homebrew postgres currently creates an account with the same name as the installing user, but no password. E.g. after my initial install (username david):

根据tadman 的评论,Homebrew postgres 目前创建了一个与安装用户同名的帐户,但没有密码。例如在我初始安装后(用户名david):

$ psql postgres
psql (12.2)
Type "help" for help.

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 david     | Superuser, Create role, Create DB, Replication, Bypass RLS | {}