Ravi Kumar SIngh
Ravi Kumar SIngh

Reputation: 321

node with postgres createdb raise error of role does not exists

I am building a api in node using postgresql. I am using sequelize as ORM. and when I am running following command to create database:

createdb bookstore

I am getting following error:

createdb: could not connect to database template1: FATAL:  role "ubox18" does not exist

Below is my configuration file:

{
  "development": {
    "username": "postgres",
    "password": "postgres",
    "database": "bookstore",
    "port": 5432,
    "host": "127.0.0.1",
    "dialect": "postgres"
  },
  "test": {
    "username": "postgres",
    "password": "postgres",
    "database": "database_test",
    "host": "127.0.0.1",
    "dialect": "postgres"
  },
  "production": {
    "username": "postgres",
    "password": "postgres",
    "database": "database_production",
    "host": "127.0.0.1",
    "dialect": "postgres"
  }
}

Can anyone help what I am missing here?

Upvotes: 0

Views: 265

Answers (1)

Try:

createdb -U postgres bookstore

The 'createdb' utility pick the database user from the OS user, unless you choose another database user with the option -U

Upvotes: 1

Related Questions