Postgres密码validation失败
我在Ubuntu Server 13.10上安装了PostgreSQL 9.1和pgadmin3。
我配置了postgresql.conf: listen_addresses = '*'
我也通过改变对等连接到md5
来配置ph_hba.conf
另外我通过以下方式重置postgres的密码: sudo password postgres
然后使用sudo /etc/init.d/postgresql restart
服务
之后我尝试连接到默认的PostgreSQL模板数据库:
sudo -u postgres psql template1
但登录失败并显示以下错误消息:
psql: FATAL: password authentication failed for user "postgres"
然后我尝试从pgadmin登录,这给了我同样的错误。
我在这里看到它可能是密码到期日期错误PostgreSQL用户更改密码后无法连接到服务器
但我无法解决它因为我无法使用psql登录。 现在有人如何解决这个问题?
编辑
ph_hba文件:
这里
截图:
您将unix用户“postgres”的密码与数据库用户“postgres”的数据库密码混淆。 这些都不一样。
您已将自己锁定,因为您为数据库用户postgres
启用了md5
身份validation,而没有为数据库用户postgres
设置密码。
在pg_hba.conf
的顶部添加一个新行:
local postgres postgres peer
然后重启/重新加载PostgreSQL并:
sudo -u postgres psql
从结果提示:
ALTER USER postgres PASSWORD 'my_postgres_password';
然后删除你添加到pg_hba.conf
的行并再次重启Pg。 您现在可以使用上面设置的密码作为postgres
用户连接到PostgreSQL。
要了解更多信息,请阅读用户手册的“客户端身份validation”一章和 pg_hba.conf
上的文档 。
尝试使用以下命令修改数据库template1的密码:
$ psql -c "ALTER USER postgres WITH PASSWORD 'yourPassword'" -d template1
在你的pg_hba.conf中
# IPv4 local connections: # TYPE DATABASE USER CIDR-ADDRESS METHOD host all all 127.0.0.1/32 trust
如果它不起作用然后尝试
host all all your_ip/32 trust
然后重新启动你的数据库它会工作正常..如果你信任,那么你不需要密码,如果你制作MD5然后它会问密码…