4

I'm trying to connect postgres database from sequelize (node.js).But sequelize throws error like ERROR: database "public" does not exist.

The database url is given below:

postgres://postgres:root@localhost:5432/public

The show db result is given below: enter image description here

I have modified the database url as follows: postgres://postgres:root@localhost:5432/postgres, where postgres is valid database.Please find the attached image below:

enter image description here

3
  • 2
    database and schema in postgresql are not the same object .. you should provide the database name not the schema name Commented Dec 14, 2018 at 8:50
  • A database and schema are two different things. You connect to a database which in turn contains many schemas in which you create tables (and other objects). So, to create a table you provide a schema name. So you should use create table public.sequalizemeta ... Commented Dec 14, 2018 at 9:11
  • Please read meta.stackoverflow.com/questions/285551/… and the accepted answer Commented Dec 14, 2018 at 9:11

2 Answers 2

2

database and schema in postgresql are not the same object .. you should provide the database name not the schema name

you could get the list of the database using

psql -U pgadmin -l
Sign up to request clarification or add additional context in comments.

Comments

0

The postgres database is a default database meant for use by users, utilities and third party applications.

If you don't specify a database while connecting to postgres (using, day, psql), it will connect to postgres DB.

It is possible that you connected to postgres without specifying the DB and created the tables. Hence they were created in postgres DB.

References:

  1. https://www.postgresql.org/docs/15/app-initdb.html
  2. https://stackoverflow.com/a/2411860/12242023

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.