gpt4 book ai didi

javascript - 错误: password authentication failed for user "myuser"

转载 作者:行者123 更新时间:2023-12-03 04:32:38 25 4
gpt4 key购买 nike

如果我在/etc/postgresql/9.4/main/pg_hba.conf 中有一条记录特别信任我的特定用户

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local all myuser trust

由于我使用的是 debian,因此我会像这样重新启动 postgresql

sudo /etc/init.d/postgresql restart

这是我对此进行测试的整个源文件:

const pg = require('pg');
const connectionString = "postgres://myuser:mypassword@localhost/mydbname";

const client = new pg.Client(connectionString);
client.connect();
const query = client.query('SELECT * FROM USERS');
query.on('end', () => { client.end(); });

这是我经常遇到的错误:

error: password authentication failed for user "myuser"
at Connection.parseE (/home/myuser/webserver/node_modules/pg/lib/connection.js:539:11)
at Connection.parseMessage (/home/myuser/webserver/node_modules/pg/lib/connection.js:366:17)
at Socket.<anonymous> (/home/myuser/webserver/node_modules/pg/lib/connection.js:105:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:551:20)

还值得注意的是,执行以下操作:

psql -h localhost -U myuser mydb

我在这里做错了什么?

最佳答案

the documentation声明,当您建立到 localhost 的 TCP 连接时,local 仅适用于 UNIX 套接字连接。

使用这样的行:

host    all    myuser    127.0.0.1/32    trust

信任使用 IPv4 的来自 localhost 的所有连接(对于 IPv6 使用地址 ::1/128)。

关于javascript - 错误: password authentication failed for user "myuser",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43426652/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com