新手问题 PostgresSQL 创建新用户的问题

springwq · 2014年12月18日 · 最后由 springwq 回复于 2014年12月18日 · 2563 次阅读

PG 创建一个新用户是不是必须和系统的用户 match 呢? 比我 的系统用户是 USER_A, 然后我用 postgres 创建了一个 PostgresSQL 的用户 USER_B, 貌似 USER_B 无法创建 DB 了。

读了官方文档,对于 PG 的 Role/User 还是比较困惑。

http://superuser.com/questions/507721/user-permissions-for-creating-postgresql-db

It appears that you have a database user named kuser, but there is no system user with that name. This is why you're able to get a postgres prompt as that user, but sudo fails.

我的需求很简单,就是再创建一个用户作为日常管理 PG 用。

  1. 不需要
  2. 要给 USER_B 权限

创建 role 的时候给上 SUPERUSER 标记。

#2 楼 @hxgdzyuyi 是 Peer Authentication, 除了 postgres 这个 SUPERUSER,还会创建一个和 Sytem User 一样的 Postgres user,如果 database.yml 了使用了其它的用户名,就报错了 #3 楼 @debugger 这样就两个 SUPERUSER 了。 #1 楼 @azhao 我在 Ubuntu 上,如果用了一个不是 system User 的 Postgres user, 就一直报错,后来还是改成 system user 来管理 PG 了。默认的 Trust Authentication 也挺方便的,System user 可以直接连接 PG。

http://www.postgresql.org/docs/9.3/static/auth-methods.html#AUTH-TRUST

需要 登录 后方可回复, 如果你还没有账号请 注册新账号