Postgres 的 Sequelize 和对等身份验证? [英] Sequelize and peer authentication for Postgres?

查看:41
本文介绍了Postgres 的 Sequelize 和对等身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 postgres 数据库已设置为使用对等身份验证,但我不确定如何告诉 Sequelize 使用此方法?

My postgres database has been set up to use peer authentication and I am not sure how to tell Sequelize to use this method?

目前我们正在使用以下内容:

Currently we are using the following:

new Sequelize("postgres://127.0.0.1/dbname", {});

我也尝试了以下方法,但没有用

I also tried the following which did not work

new Sequelize("postgresql:///dbname?host=/var/lib/postgresql");

在这两种情况下,我都收到错误:

In both cases I get the error:

SequelizeBaseError: password authentication failed for user"

有人可以帮忙吗?

推荐答案

更多的探索表明以下内容可以解决问题:

A bit more exploration shows the following will do the job:

new Sequelize('mydb', undefined, undefined, {
     host: '/var/run/postgresql',
     dialect: 'postgres'
   });

实际连接由包 'pg' 处理,这在 中有记录问题.

The actual connection is handled by the package 'pg' and this was documented in an issue.

注意,我已经测试过它可以与 pg@6.4.1 和 sequelize@4.4.2 一起使用.

Note, I have tested this to work with pg@6.4.1 and sequelize@4.4.2.

这篇关于Postgres 的 Sequelize 和对等身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆