gpt4 book ai didi

javascript - postgres 与 node.js 连接中的 SASL 错误

转载 作者:行者123 更新时间:2023-12-04 14:07:23 29 4
gpt4 key购买 nike

尝试连接到我的数据库时出现以下错误:

Conexão estbabelecida com sucesso
Acessar http://localhost:3000
Servidor executando na porta 3000
C:\Users\lopes\Desktop\Javascript\novo-projeto\ExpressEWebpack\node_modules\pg\lib\sasl.js:24
throw new Error('SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string')
^

Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
at Object.continueSession (C:\Users\lopes\Desktop\Javascript\novo-projeto\ExpressEWebpack\node_modules\pg\lib\sasl.js:24:11)
at Client._handleAuthSASLContinue (C:\Users\lopes\Desktop\Javascript\novo-projeto\ExpressEWebpack\node_modules\pg\lib\client.js:257:10)
at Connection.emit (events.js:315:20)
at C:\Users\lopes\Desktop\Javascript\novo-projeto\ExpressEWebpack\node_modules\pg\lib\connection.js:114:12
at Parser.parse (C:\Users\lopes\Desktop\Javascript\novo-projeto\ExpressEWebpack\node_modules\pg-protocol\dist\parser.js:40:17)
at Socket.<anonymous> (C:\Users\lopes\Desktop\Javascript\novo-projeto\ExpressEWebpack\node_modules\pg-protocol\dist\index.js:11:42)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
[nodemon] app crashed - waiting for file changes before starting...
这是我的连接代码
require('dotenv').config();
const express = require('express');
const app = express();
const { Sequelize } = require('sequelize');
const sequelize = new Sequelize(process.env.DB_URL);

try {
sequelize.authenticate();
console.log('Conexão estbabelecida com sucesso')
}catch{
console.log('Erro ao estabelecer conexão');
}

const session = require('express-session');
const flash = require('connect-flash');

const routes = require('./routes')
const path = require('path');


app.use(express.urlencoded({ extended:true }));

app.use(express.static(path.resolve(__dirname, 'public')));

const sessionOptions = session({
secret:process.env.cookie_secret,
store: new (require('connect-pg-simple')(session))(),
resave: false,
saveUninitialized: false,
cookie: {maxAge: 1000 * 60 * 60 * 24 * 7}
});

app.use(sessionOptions);
app.use(flash());

app.set('views', path.resolve(__dirname, 'src', 'views'));
app.set('view engine', 'ejs');

app.use(routes);

app.listen(3000, () => {
console.log('Acessar http://localhost:3000');
console.log('Servidor executando na porta 3000');
});
我有这个错误,但我的数据库根本没有密码,我没有密码的事实可能会干扰连接?在某种程度上,密码因为没有值(value)而收到空值?我试图解决,看看 sasl.js 上有什么,但没有太大帮助

最佳答案

在您的 pg_hba.conf 文件(在 Windows 上,目录是\Program Files\PostgreSQL\13\data)将 IPv4 和 IPv6 本地连接的方法更改为 信任 . 急停-sha-256 加密机制需要一个密码,这就是它失败的原因。

关于javascript - postgres 与 node.js 连接中的 SASL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67348084/

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