postgres用户无法连接到postgres用户创建的数据库。
postgres=> CREATE DATABASE mydb ENCODING 'UTF8' ;
CREATE DATABASE
postgres=> \connect "mydb";
FATAL: Peer authentication failed for user "postgres"
Previous connection kept
这与postgresql的谷歌云版本有关吗?
答案 0 :(得分:0)
为PostgreSQL实例创建新的Cloud SQL时,必须为默认用户帐户'postgres'设置密码[1]。 “对等身份验证仅适用于本地连接”[2]。 pg_hba.conf文件中的身份验证方法字段'auth-method'应该使用'md5'而不是'peer'[2],因为为默认用户帐户设置了密码。这里回答了类似的错误[3]。
[1] https://cloud.google.com/sql/docs/postgres/create-manage-users#user-root
[2] https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html