我无法连接到本地服务器上我自己的 postgres 数据库。 我用谷歌搜索了一些类似的问题并提出了本手册 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
然后我创建一个用户并为其分配一个密码:
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
可能是什么问题?
最佳答案
您创建的角色不允许登录,您必须授予该角色登录权限。
一种方法是作为 postgres
用户登录并更新角色:
psql -U postgres
登录后,输入:
ALTER ROLE "asunotest" WITH LOGIN;
这是文档 http://www.postgresql.org/docs/9.0/static/sql-alterrole.html
关于PostgreSQL:不允许角色登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35254786/