Postgres中createdb的问题 [英] Problems with createdb in postgres

查看:219
本文介绍了Postgres中createdb的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须对分布在不同机器上且都在linux上运行的多个postgresql数据库进行模拟。

I have to run a simulation with several postgresql databases spread on different machines which all of them are running linux.

我成功地从源代码编译并构建了postgresql并且我也可以运行服务器,但是当我尝试使用以下命令创建新的数据库时:

I successfully compiled and built postgresql from the source code and I can also run the server, but when I try to create a new db with this command:

./postgresql/bin/createdb db1

我收到此错误:

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

其中giulio是我用来访问所有计算机的用户名。

where giulio is my username to access all the machines.

在某些计算机上它可以工作,而在其他计算机上则不能。我真的无法弄清楚问题的根源。我想这与postgres的访问控制有关。

On some machine it works while on other it does not. I really cannot figure out the root of the problem. I suppose it is something related with the access control of postgres.

我在Google上做了几项研究,但未能找到并解决问题。

I did several research on google but I was not able to found and to solve the problem.

有有人知道如何获得这项工作吗?

Does anyone know how to get this work?

谢谢

-朱利奥

推荐答案

我假设在已经知道用户 giulio的计算机上,您执行了 initdb 正是这个用户使他成为数据库超级用户。 inidb(1)的引号(重点是我的):

I would assume that on the machines where the user "giulio" is already known, you executed initdb with exactly this user making him the DB superuser. A quote from inidb(1) (emphasis mine):


-用户名=用户名
选择数据库超级用户的用户名。 这默认将
设为运行initdb的有效用户的名称。

的确不重要,超级用户的名字是什么,但可以选择
来保留习惯名称 postgres ,即使操作系统的用户名
也不同。

--username=username Selects the user name of the database superuser. This defaults to the name of the effective user running initdb. It is really not important what the superuser's name is, but one might choose to keep the customary name postgres, even if the operating sys‐ tem user's name is different.

我认为您确实与其他用户执行过 initdb 的其他机器,希望使用 postgres

On the other machines I assume you did execute initdb with another user, hopefully using postgres.

为了回到我建议的标准轨道,您删除 giulio是超级用户的计算机上的数据库集群,并使用标准的 postgres 用户。然后添加另一个用户 giulio。由于某些脚本/程序希望使用名为 postgres 的超级用户帐户,因此可以避免日后的混乱。

In order to get back on the standard track I propose, that you delete the database cluster on the machines where "giulio" is the superuser and setup a new database cluster using the standard postgres user. Then add another user "giulio". This will avoid more confusion down the road as some scripts/programs expect a superuser account named postgres.

这篇关于Postgres中createdb的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆