为什么当我尝试使用 NodeJS 和 MariaDB 时会"Unknown encoding: <ref *1> Handshake"?



我有以下NodeJs代码。。。

import mariadb from "mariadb";
class MariaConnector{
constructor(
password = process.env.SQL_PASSWORD,
host="192.168.1.193",
user="API",
database = "SITE"){
this.host = host;
this.password = password;
this.user = user;
this.database = database;
this.connectionLimit = 5;
}
get connection(){
console.log(`The password is ${this.password}`)
// return this.pool.getConnection();
return mariadb.createConnection(this)
}
}

当我尝试运行程序,它调用get connection时,密码打印出来很好,但我得到。。。

_stream_writable.js:296
throw new ERR_UNKNOWN_ENCODING(encoding);
^
TypeError [ERR_UNKNOWN_ENCODING]: Unknown encoding: <ref *1> Handshake {
_events: [Object: null prototype],
_eventsCount: 1,

我希望它能工作,因为我在Desktop SQL客户端中使用的配置完全相同,工作正常。

将mariadb模块更新到最新版本(2.5.2(对我来说很有效。你可以使用yarn upgrade或CCD_ 2。

相关内容

最新更新