首先打开data目录下的pg_hba.conf配置文件,找到:
# IPv4 local connections: host all all 127.0.0.1/32 md5
然后把md5改成trust,重新启动。
psql -d template1 -U postgres -c "alter role postgres password ‘123456’;"
新密码既为123466,此时可以将pg_hba.conf恢复