node.js - '错误:Node.js 中的数据库“根”不存在'
问题描述
我正在运行与 Postgres 数据库对话的 NodeJS 微服务。但是当我尝试启动服务时,我遇到了错误。我不知道为什么会弹出这个错误。
错误:
UnhandledPromiseRejectionWarning: Unhandled promise rejection(rejection id:1): error: database “root” does not exist
我的数据库连接详细信息:
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
});
推荐阅读
- mysql - 无法使用命令行启动 MySQL 服务(Windows 10)
- mysql - MySQL lower_case_file_system 更改(OFF 到 ON)
- python - 在python中按列名调用分组数据框
- ionic-framework - 如何让我的实时图表从 html5 iframe 加载到 Ionic
- ios - 静默推送不触发代码执行
- python - 如何使用 docker-compose 设置一个容器以允许其整个卷访问另一个容器
- javascript - 如何通过参数名称将数据传递给函数?
- vue.js - 如何从组件(b-card)传递选定的选项并将其传递给vue中的多选组件
- clickhouse - clickhouse-client 收到错误“从套接字读取时超时”
- mongodb - 如何使用聚合从 mongoDB 中对象的嵌套数组中提取信息