操作系統:Debian8
登錄pg時可能會有提示錯誤:
$ psql -U user1 -d exampledb psql: 致命錯誤: 對用戶"user1"的對等認證失敗
打開以下文件,
$ sudo vi /etc/postgresql/9.4/main/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5
將 peer 改為md5:
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only 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
然后重啟服務:
$ sudo service postgresql restart
再登錄即可:
$ psql -U user1 -d exampledb
-- End --