在 OSX 上创建“postgres”用户帐户?

Wei*_*ier 7 unix user-accounts postgresql macos

我只是犯了一个错误:我在 Mac OSX 10.6.7 上安装了 PostgreSQL,当我想连接到它时,我做了su postgres,然后它要求我输入密码,我确实sudo passwd postgres将密码更改为我知道的内容。

问题是,正如这里所解释的,这为 postgres 创建了一个 Unix 用户帐户,之后我的 Mac 上有两个用户:我和 postgres。

所以我删除了postgres帐户。现在我无法连接到 postgres 因为我不能su postgres。如何重新创建一个我可以安全使用的“锁定”用户帐户 postgres(sudo su postgres按照我以前应该做的那样做)?

编辑:添加了 Mac OS X 版本

小智 3

来自以下堆栈溢出:

/sf/ask/1071127851/

CREATE USER postgres SUPERUSER;
CREATE DATABASE postgres WITH OWNER postgres;
Run Code Online (Sandbox Code Playgroud)

  • 问题是如何创建运行 PostgreSQL 的 macOS 用户,而不是如何创建 PostgreSQL 数据库角色。请参阅[第 18 章。服务器设置和操作:18.1。PostgreSQL 用户帐户](https://www.postgresql.org/docs/current/postgres-user.html) 与 [PostgreSQL 命令`CREATE ROLE`](https://www.postgresql.org/docs/current /sql-createrole.html)。(注意:[PostgreSQL 命令 `CREATE USER`](https://www.postgresql.org/docs/current/sql-createuser.html)“现在是 CREATE ROLE 的别名。”) (2认同)