'错误:Node.js中的数据库“root”不存在
我正在运行与Postgres数据库对话的NodeJS微服务。但是,当我尝试启动服务时,我遇到了错误。我不知道为什么会出现这个错误。
错误:
UnhandledPromiseRejectionWarning: Unhandled promise rejection(rejection id:1): error: database “root” does not exist
我的DB连接细节:
const pg = require(“pg”);
const client = new pg.Client({
host: “txslmxxxda6z”,
user: “mom”,
password: “mom”,
db: “mom”,
port: 5025
});
回答如下:
我自己能解决这个问题。问题出在连接配置中。它应该是数据库而不是数据库,因此这导致了问题。 PFB回答
const client = new pg.Client({
host: “txslmoxxx6z”,
user: “mom”,
password: “mom”,
//change db to database
database: “mom”,
port: 5025
});