我通过homebrew在我的Mac上安装了postgresql。它说它没有创建一个postgres账户,而是使用了我的用户名的账户。然而,当我运行psql
命令时失败了,因为当我输入我的密码时,它说密码错误。我已经重新尝试了几次,以确保我没有输错密码。那么它给我的密码是什么?
我通过homebrew在我的Mac上安装了postgresql。它说它没有创建一个postgres账户,而是使用了我的用户名的账户。然而,当我运行psql
命令时失败了,因为当我输入我的密码时,它说密码错误。我已经重新尝试了几次,以确保我没有输错密码。那么它给我的密码是什么?
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 | {}
psql -U postgres
命令,然后输入postgres
作为密码。 - Pratik Parmarpsql
即可进入。
如果不能进入,则可能还安装了Postgres应用程序。如果卸载该应用程序,则不会再出现用户冲突问题。
database "<your_username>" does not exist
- Homebrew会将DB用户安装为<your_username>,但保持默认的DB名称为“postgres” - 因此使用psql -d postgres
登录将起作用。 - jester66OS X用户,拥有PostgreSQL文件和进程。在安装PostgreSQL时,您使用了自己的用户账户。
能够登录PostgreSQL数据库的PostgreSQL用户。默认情况下,该用户是内部于您的PostgreSQL实例的,与任何OS X用户无关。
我曾经也遇到过同样的问题,原来是我已经安装了Postgres,但是并没有使用Homebrew进行安装。 在删除了那个安装之后,使用Homebrew进行安装就成功了,并且不再提示我输入密码。
psql postgres
来解决它。
它的显示如下:➜ ~ psql postgres
psql (14.7 (Homebrew))
Type "help" for help.
postgres=#
但我无法使用psql -U postgres
,它显示如下:
➜ ~ psql -U postgres
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL: role "postgres" does not exist
在 MacOS Ventura 13.5.1 上使用 Homebrew 安装的 PostgreSQL 5:
用户名:我的登录用户 密码:postgress
如何查找:
在终端上:
psql postgres
postgres=# \du
postgres=# \q
然后:
psql -U usernameListedAbove postgres
我遇到了同样的问题,解决方法如下。
这可能是由于您之前从其他来源安装了postgres
,然后尝试卸载。它确实在您的系统上留下了postgres
用户帐户。从系统偏好设置
中进入用户和账户
。从那里删除postgres
用户帐户。现在重新启动,然后尝试使用brew进行安装。这应该有效。
我使用Homebrew安装了Postgres 14。第一次登录时,我尝试使用postgres
作为密码,并且成功了。
hackyroot@Root-MacBook-Air ~ % psql -U postgres
Password for user postgres:
psql (14.8 (Homebrew), server 15.3)
WARNING: psql major version 14, server major version 15.
Some psql features might not work.
Type "help" for help.
postgres=#