借鉴

https://my.oschina.net/u/3371661/blog/3040763

一直以为是密码设错了,其它应该是权限问题【个人理解】

alter role postgres with password '123';

解决方法
1、编辑pg_hba.conf,将md5认证修改成trust认证,编辑后退出保存

3、psql连接,用alter role修改密码
[postgres @ pgsqldb-master bin]$ psql
psql (9.2.3)
Type "help" for help.

postgres=# alter role postgres with password '123';
ALTER ROLE
postgres=#

4、退出psql
5、编辑pg_hba.conf,将turst认证修改成md5认证,编辑后退出保存

重启

systemctl restart postgresql-9.6

在postgres用户下执行下面,输入密码可以进去,就说明密码设置成功了。

psql -h 127.0.0.1 -U postgres

这时如果pg_hba.conf如果有远程配置

host    all             all             0.0.0.0/0            md5

postgres.conf中

listen_addresses = '*'

远程则也可以了

04-23 10:43