简体   繁体   English

错误:用户“ myuser”的密码身份验证失败

[英]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.

相关问题 UnhandledPromiseRejectionWarning:错误:用户密码认证失败 - UnhandledPromiseRejectionWarning: error: password authentication failed for user 用户“root”、postgresSQL 和 docker 的密码验证失败 - password authentication failed for user "root", postgresSQL and docker Linux - NodeJS、Express、PostgreSQL - 错误处理程序:用户“root”的密码验证失败 - Linux - NodeJS, Express, PostgreSQL - ErrorHandler: password authentication failed for user "root" 在javascript中散列密码以进行用户身份验证 - Hashing password in javascript for user authentication Adonisjs身份验证密码不匹配错误 - Adonisjs Authentication Password mismatch error 使用javascript获取用户和密码身份验证(入门) - Getting user and password authentication with javascript (Beginner) 如何解决这个问题是节点“错误:用户验证失败:用户名:路径`用户名`是必需的。密码:路径`密码`是必需的。” - how to fix this is node"Error: User validation failed: username: Path `username` is required. password: Path `password` is required." Google身份验证:无法将用户序列化为会话 - Google authentication: failed to serialize user into session firebase SERVER_ERROR的电子邮件/密码身份验证 - email/password authentication for firebase SERVER_ERROR Javascript:用户身份验证JSON错误 - Javascript: User Authentication JSON Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM