[英]error: password authentication failed for user “myuser”
If I have a record in /etc/postgresql/9.4/main/pg_hba.conf which specifically trusts my specific user 如果我在/etc/postgresql/9.4/main/pg_hba.conf中有一条记录,该记录专门信任我的特定用户
# TYPE DATABASE USER ADDRESS METHOD
local all myuser trust
Since I'm on debian I restart postgresql like this 由于我使用的是Debian,所以我像这样重新启动了postgresql
sudo /etc/init.d/postgresql restart
Here is my entire source file testing this out: 这是我整个源文件的测试结果:
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(); });
and this is the error I consistently get: 这是我一直得到的错误:
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)
It's also worth noting that doing the following works: 还值得注意的是,请执行以下工作:
psql -h localhost -U myuser mydb
What am I doing wrong here? 我在这里做错了什么?
As the documentation states, local
is only for UNIX socket connections, while you are establishing a TCP connection to localhost
. 如文档所述, local
仅用于UNIX套接字连接,而您正在建立到localhost
的TCP连接。
Use a line like this: 使用这样的行:
host all myuser 127.0.0.1/32 trust
to trust all connections from localhost
using IPv4 (use the adress ::1/128
for IPv6). 以使用IPv4信任来自localhost
所有连接(对于IPv6,使用地址::1/128
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.