简体   繁体   中英

Error connecting to posgresql database using pg on windows

I've got a PostgreSQL database, definitely existing because I can connect to it and make SQL query using psql.

However, when I try to connect with node.js, using the pg client, I've got an error saying that the database does not exist.

Here is how the connection work:

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

connection.connect();

And here is the error I obtained: 在此处输入图片说明

In english: The database **camino** does not exist .

Can you enligthen me on this error?

Are you sure you have created the database camino by using the create table syntax found here: https://www.postgresql.org/docs/9.1/sql-createdatabase.html

If you have already done that, Postgresql starts with 3 default databases called: postgres, template0 and template1. Have you tried connecting to the default postgres database and confirmed that it works?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM