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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15591749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:06:21  来源:igfitidea点击:

unable to create user postgres: role "postgres" does not exists

postgresqlubuntuinstallationrole

提问by Kaushik Thirthappa

i am on ubuntu 12.04 server and i am trying to install postgresql. As of now, i have successfully installed it but unable to configure it. I need to create a role to move ahead and i ran this command in terminal :

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

root@hostname: createuser -s -r postgres

root@hostname: createuser -s -r postgres

and it said :

它说:

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

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

Fine, so i did :

很好,所以我做了:

su - postgres

su - postgres

and then tried again

然后再试一次

postgres@hostname: createuser -s -r postgres

postgres@hostname: createuser -s -r postgres

and i got the error

我得到了错误

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

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

and i get the same error when i do

当我这样做时,我得到了同样的错误

psql -d dbname

psql -d dbname

Its like a loop, i am unable to create a role postgresbecause a role postgresdoes not already exist.

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

How do i fix this ?

我该如何解决 ?

The postgres version seems to be 9.1.x and the ubuntu version is 12.10

postgres 版本好像是 9.1.x,ubuntu 版本是 12.10

采纳答案by Kaushik Thirthappa

Turns out i had installed postgres-xcand postgresqlon my machine. I had to knock off postgres-xc completely. And it was a little difficult to do that because, there was always an error --purge remove postgres-xcand the uninstallation could not continue.

原来我已经安装postgres-xcpostgresql在我的机器上。我不得不完全关闭 postgres-xc。这样做有点困难,因为总是出现错误--purge remove postgres-xc并且卸载无法继续。

There seems to be some kind of a packaging bug. (details on launchpad).

似乎存在某种包装错误。(有关启动板的详细信息)。

Eventually, i ended up doing thisto make it work.

最后,我终于实现了这个以使其工作。

After that i uninstalled postgresql and installed it back to make it work.

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

回答by 1ac0

Read postgresql tutorialit doesn't matter if it's Ubuntu or other Linux.

阅读postgresql 教程,不管是 Ubuntu 还是其他 Linux。

EDIT before creating role or anything else on fresh install you need to create database cluster: have you created it?

在创建新安装的角色或其他任何内容之前进行编辑,您需要创建数据库集群:您创建了吗?

initdb -D /usr/local/pgsql/data

You need to be logged as user postgreson linux machine. Hereis more info.

您需要postgres在 linux 机器上以用户身份登录。这里有更多信息。