最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

'错误:Node.js中的数据库“root”不存在

运维笔记admin10浏览0评论

'错误:Node.js中的数据库“root”不存在

'错误: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
 });
发布评论

评论列表(0)

  1. 暂无评论