PostgreSQL:不允许角色登录 [英] PostgreSQL: role is not permitted to log in
问题描述
我无法连接到本地服务器上的自己的postgres数据库。
我用Google搜索了类似的问题,并提出了本手册
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屋!