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

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

问题描述

我正在 Windows 中设置我的 PostgreSQL 9.1.

I'm setting up my PostgreSQL 9.1 in windows.

我不能用 PostgreSQL 做任何事:can't createdb, can't createuser;所有操作都返回错误信息

I can't do anything with PostgreSQL: can't createdb, can't createuser; all operations return the error message

致命:角色根不存在
root 是我在安装 Postgresql

但我可以使用以下方法进行连接:

But I am able to connect using:

 username : postgres  

如何使用角色 root 连接到 postgres?
这里但无法找出 windows7 的解决方案

How can I connect to postgres using role root?
There is a solution mentioned for linux platforms using su command here but not able to figure out solution for windows7

提前致谢

推荐答案

如果您想使用用户名 root 登录 Postgres,您需要先创建一个这样的用户.

If you want to login to Postgres using the username root you need to first create such a user.

您首先需要以 Postgres 超级用户身份登录.这通常是 postgres(并在安装期间指定):

You first need to login as the Postgres super user. This is typically postgres (and is specified during installation):

psql -U postgres ....

然后你可以创建角色和数据库:

then you can create roles and databases:

psql (9.4.0)
Type "help" for help.

postgres=# create user root with password 'verysecret';
CREATE ROLE
postgres=# \q

c:\
c:\>psql -U root postgres
psql (9.4.0)
Type "help" for help.

postgres=>

以超级用户身份登录,您还可以授予 root 用户必要的权限.

Logged in as the superuser you can also grant the root user the necessary privileges.

psql 的所有参数 记录在手册.

手册中还记录了创建用户和数据库:

Creating users and databases is also documented in the manual:

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

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