javascript - 在 Windows 上使用 gpg 连接到 postgresql 数据库时出错

标签 javascript node.js postgresql psql pg

我有一个 PostgreSQL 数据库,肯定存在,因为我可以连接到它并使用 psql 进行 SQL 查询。

但是,当我尝试使用 pg 客户端连接 node.js 时,我收到一条错误消息,指出数据库不存在。

这是连接的工作方式:

var pg = require('pg');
const connection = new pg.Client({
   host: 'localhost',
   port: 5432,
   database: 'camino',
   user: 'postgres',
  password: 'postgres'
})

connection.connect();

这是我得到的错误: enter image description here

英语:数据库 **camino** 不存在

你能告诉我这个错误吗?

最佳答案

您确定您已经使用此处的创建表语法创建了数据库卡米诺:https://www.postgresql.org/docs/9.1/sql-createdatabase.html

如果您已经这样做了,Postgresql 将以 3 个默认数据库开始,分别称为:postgres、template0 和 template1。您是否尝试连接到默认的 postgres 数据库并确认它可以正常工作?

关于javascript - 在 Windows 上使用 gpg 连接到 postgresql 数据库时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55060256/

相关文章:

javascript - 如何从异步调用返回响应?

javascript - 为什么 jQuery 每次都输出相同的 rel?

javascript - 如何获取特定用户是否在线?

node.js - TypeScript 构建错误 TS5023

javascript - 我可以使用 Moment.js 分配 "now"的内容吗?

node.js - node js ffmpeg complexfilter覆盖另一个视频

sql - 有效地复制 PostgreSQL 表中的一些行

sql - Postgres - 将两列聚合成一个项目

python - Django 不迁移应用程序

javascript - 使用来自后端的 Regexp 进行 Angular 电子邮件验证