- 我安装
PostgreSQL
在EC2
机器上,现在我想更改用户的密码postgres
- 我愿意
$ sudo -u postgres psql psql (9.1.5) Type "help" for help. postgres=# ALTER USER postgres WITH PASSWORD 'newpasswd'; ALTER ROLE
- 然后我退出shell并尝试使用新密码登录
$ psql -U postgres -W Password for user postgres: psql: FATAL: Peer authentication failed for user "postgres"
我的PostgreSQL
版本是
$ psql --version
psql (PostgreSQL) 9.1.5
contains support for command-line editing
我做错了什么?
谢谢
更新
我进行了更改pg_hba.conf
,这就是现在的样子
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
#local all all peer
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
然后我重新启动了postgres
$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.1 database server [ OK ]
我尝试再次登录,但失败了
$ psql -U postgres -W
Password for user postgres:
psql: FATAL: Peer authentication failed for user "postgres"