簡體   English   中英

“錯誤:Node.js中的數據庫“根”不存在”

[英]'Error: database “root” does not exist' in 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
  });

我自己就能解決這個問題。 問題出在連接配置中。 它應該是數據庫,而不是db,所以這是導致問題的原因。 PFB答案

 const client = new pg.Client({
        host: “txslmoxxx6z”,
        user: “mom”,
        password: “mom”,
        //change db to database
        database: “mom”,
        port: 5025
 });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM