谷歌云postgresql - 不能\ postgresql用户连接到数据库

时间:2018-04-14 03:03:17

标签: postgresql google-cloud-sql

postgres用户无法连接到postgres用户创建的数据库。

postgres=> CREATE DATABASE mydb  ENCODING 'UTF8' ;
CREATE DATABASE
postgres=> \connect "mydb";
FATAL:  Peer authentication failed for user "postgres"
Previous connection kept

这与postgresql的谷歌云版本有关吗?

1 个答案:

答案 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

[3] Getting error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails