角色 "postgres" 不存在;无法创建用户

role "postgres" does not exist; cannot createuser

我在 Linux 薄荷肉桂 2.2.16.

在启动 Rails 和 运行 的过程中,我遇到了 Postgres 问题。

postgres@BL ~ $ psql --version
psql (Postgres-XC) 1.1
(based on PostgreSQL) 9.2.4

我无法使用常用用户名进行任何操作,因此我使用

更改为默认用户
sudo su - postgres

我无法使用 createuser 进行任何操作。

postgres@BL ~ $ psql
psql: FATAL:  role "postgres" does not exist

postgres@BL ~ $ createuser -s -U $USER
createuser: could not connect to database postgres: FATAL:  role "postgres" does not exist

postgres@BL ~ $ sudo -u postgres createuser newname
Sorry, user postgres is not allowed to execute '/usr/bin/createuser newname' as postgres on BL.

postgres@BL ~ $ which psql
/usr/bin/psql
postgres@BL ~ $ psql \l
psql: FATAL:  role "postgres" does not exist

您必须以超级用户身份向 psql 进行身份验证才能管理用户。 例如

psql -U root

之后

create user paige with password 'paige';

在彻底研究问题并撕掉多根头发后,我认为这是 packaging/installation 问题的一些变体,类似的问题在此处记录:unable to create user postgres: role "postgres" does not exists

我完全卸载了,如下所示,然后在没有 postgresql-xc

的情况下重新安装

How to thoroughly purge and reinstall postgresql on ubuntu?

新安装符合用户 "postgres" 的预期行为,我能够将自己添加为超级用户并创建新数据库。经过一些 post-安装 finagling,Rails 似乎是 运行 并且与 postgres 一起玩得很好。