day*_*mer 9 postgresql postgresql-9.1
PostgreSQL
在EC2
机器上,现在我想更改用户的密码postgres
Run Code Online (Sandbox Code Playgroud)$ sudo -u postgres psql psql (9.1.5) Type "help" for help. postgres=# ALTER USER postgres WITH PASSWORD 'newpasswd'; ALTER ROLE
Run Code Online (Sandbox Code Playgroud)$ 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
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
谢谢
更新
我进行了更改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
Run Code Online (Sandbox Code Playgroud)
然后我重新启动了 postgres
$ sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.1 database server [ OK ]
Run Code Online (Sandbox Code Playgroud)
我再次尝试登录,但失败了
$ psql -U postgres -W
Password for user postgres:
psql: FATAL: Peer authentication failed for user "postgres"
Run Code Online (Sandbox Code Playgroud)
就像 willglynn 说的,它可能是你的 pg_hba.conf 文件。
如果您有以下行:
local all all peer
Run Code Online (Sandbox Code Playgroud)
然后将其更改为:
local all all md5
Run Code Online (Sandbox Code Playgroud)
然后应该让您使用新密码登录(假设您正确提供了它):)
小智 5
除了更改pg_hba.conf
文件之外,我只想添加
local all all peer
Run Code Online (Sandbox Code Playgroud)
到
local all all md5
Run Code Online (Sandbox Code Playgroud)
根据接受的答案,在执行 OP 所做的相同操作后,我可以登录的唯一方法是-h
在尝试登录时传递标志。
$ psql -U postgres -h localhost
Run Code Online (Sandbox Code Playgroud)
希望这会对将来的某人有所帮助。这让我发疯了!
归档时间: |
|
查看次数: |
34060 次 |
最近记录: |