PostgreSQL 错误:致命:角色“用户名"不存在 [英] PostgreSQL error: Fatal: role "username" does not exist

查看:30
本文介绍了PostgreSQL 错误:致命:角色“用户名"不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置我的 PostgreSQL 9.1.我不能用 PostgreSQL 做任何事情:不能 createdb,不能 createuser;所有操作都返回错误信息

I'm setting up my PostgreSQL 9.1. I can't do anything with PostgreSQL: can't createdb, can't createuser; all operations return the error message

Fatal: role h9uest does not exist

h9uest 是我的账号名,我在这个账号下sudo apt-get install PostgreSQL 9.1.
root 帐户仍然存在类似的错误.

h9uest is my account name, and I sudo apt-get install PostgreSQL 9.1 under this account.
Similar error persists for the root account.

推荐答案

使用操作系统用户 postgres 来创建你的数据库——只要你还没有设置建立一个数据库角色,该角色具有与您的同名操作系统用户相对应的必要权限(在您的情况下为h9uest):

Use the operating system user postgres to create your database - as long as you haven't set up a database role with the necessary privileges that corresponds to your operating system user of the same name (h9uest in your case):

sudo -u postgres -i

推荐此处这里.

然后再试一次.以系统用户 postgres 完成操作后,键入 exit.

Then try again. Type exit when done with operating as system user postgres.

使用 sudo 作为 postgres 执行单个命令 createuser,例如 drees 证明 在另一个答案中.

Or execute the single command createuser as postgres with sudo, like demonstrated by drees in another answer.

重点是使用匹配同名数据库角色的操作系统用户通过ident 身份验证.postgres 是初始化数据库集群的默认操作系统用户.手册:

The point is to use the operating system user matching the database role of the same name to be granted access via ident authentication. postgres is the default operating system user to have initialized the database cluster. The manual:

为了引导数据库系统,一个新初始化的系统总是包含一个预定义的角色.这个角色永远是超级用户",默认情况下(除非在运行 initdb 时更改)它将与初始化的操作系统用户同名数据库集群.通常,这个角色将被命名为 postgres.为了创建更多角色,您首先必须像这样连接初始角色.

In order to bootstrap the database system, a freshly initialized system always contains one predefined role. This role is always a "superuser", and by default (unless altered when running initdb) it will have the same name as the operating system user that initialized the database cluster. Customarily, this role will be named postgres. In order to create more roles you first have to connect as this initial role.

我听说过使用非标准用户名或操作系统用户不存在的奇怪设置.您需要在那里调整您的策略.

I have heard of odd setups with non-standard user names or where the operating system user does not exist. You'd need to adapt your strategy there.

阅读数据库角色客户端认证在手册中.

这篇关于PostgreSQL 错误:致命:角色“用户名"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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