无法创建用户postgres:角色“postgres”不存在

时间:2013-03-23 20:33:41

标签: postgresql ubuntu installation role

我在ubuntu 12.04服务器上,我正在尝试安装postgresql。截至目前,我已成功安装但无法配置它。我需要创建一个角色来继续前进,我在终端中运行了这个命令:

root@hostname: createuser -s -r postgres

它说:

createuser: could not connect to database postgres: FATAL: role "root" does not exist

很好,所以我做了:

su - postgres

然后再试一次

postgres@hostname: createuser -s -r postgres

我收到了错误

createuser: could not connect to database postgres: FATAL: role "postgres" does not exist

当我做

时我得到同样的错误

psql -d dbname

它就像一个循环,我无法创建角色postgres,因为角色postgres尚不存在。

我该如何解决这个问题?

postgres版本似乎是9.1.x而ubuntu版本是12.10

2 个答案:

答案 0 :(得分:9)

原来我在我的机器上安装了postgres-xcpostgresql。我不得不彻底击倒postgres-xc。这样做有点困难,因为总是出现错误--purge remove postgres-xc并且卸载无法继续。

似乎存在某种包装错误。 (details on launchpad)。

最终,我最终做了this以使其发挥作用。

之后我卸载了postgresql并重新安装它以使其正常工作。

答案 1 :(得分:1)

阅读postgresql tutorial无论是Ubuntu还是其他Linux都无关紧要。

EDIT 在全新安装上创建角色或其他任何内容之前,您需要创建数据库集群:您创建了它吗?

initdb -D /usr/local/pgsql/data

您需要在linux计算机上以用户postgres身份登录。 Here是更多信息。

相关问题