PostgreSQL: 不允许角色登录 [英] PostgreSQL: role is not permitted to log in

查看:32
本文介绍了PostgreSQL: 不允许角色登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地服务器上连接到我自己的 postgres 数据库时遇到问题.我在谷歌上搜索了一些类似的问题并想出了这本手册https://help.ubuntu.com/stable/serverguide/postgresql.html

I have trouble connecting to my own postgres db on a local server. I googled some similar problems and came up with this manual https://help.ubuntu.com/stable/serverguide/postgresql.html

所以:

pg_hba.conf 说:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 trust

然后我创建一个用户并为其分配一个密码:

then I create a user and assign a password for it:

postgres=# create role asunotest;
CREATE ROLE
postgres=# alter role asunotest with encrypted password '1234';
ALTER ROLE

但它不让我进去:

-bash-4.2$ psql -h 127.0.0.1 -U asunotest
Password for user asunotest: 1234
psql: FATAL:  role "asunotest" is not permitted to log in

可能是什么问题?

推荐答案

您创建的角色不允许登录,必须给角色权限才能登录.

The role you have created is not allowed to log in. You have to give the role permission to log in.

执行此操作的一种方法是以 postgres 用户身份登录并更新角色:

One way to do this is to log in as the postgres user and update the role:

psql -U postgres

登录后,输入:

ALTER ROLE "asunotest" WITH LOGIN;

这是文档http://www.postgresql.org/docs/9.0/static/sql-alterrole.html

这篇关于PostgreSQL: 不允许角色登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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