0

I'm using Ubuntu version 15.10. After I type rails s in the terminal to start a Ruby app and navigate to 0.0.0.0:3000, I get the following error on the web page:

ActiveRecord::NoDatabaseError at /

FATAL: database "local-election_development" does not exist Run $ bin/rake db:create db:migrate to create your database

When I type bin/rake db:create db:migrate from the terminal, I get this error:

PG::InsufficientPrivilege: ERROR: permission denied to create database

I found this answer, but I did not know how to execute the command ALTER USER new_user CREATEDB;.

How can I solve this error?

Community
  • 1
  • 1
badjr
  • 2,166
  • 3
  • 20
  • 31

2 Answers2

2

You can to enter the SQL command on the PostgreSQL console, which can be invoked with psql.

If it complains that the database does not exist, then use createdb, if the user doesn't exist, use createuser. Search for PostgreSQL-related questions if you have an issue with any of these.

Leventix
  • 3,789
  • 1
  • 32
  • 41
  • After typing psql, it asks for a password. If I forgot it, how can I reset it? – badjr Mar 05 '16 at 18:44
  • 1
    Try [this post](http://stackoverflow.com/questions/10845998/i-forgot-the-password-i-entered-during-postgres-installation) or [Google](https://www.google.co.uk/search?q=reset+postgres+password) – Leventix Mar 05 '16 at 18:48
1

Log into the postgres user:

su - postgres

Log into by typing:

psql

You should now see a prompt for postgres=#

Artyom Kalmykov
  • 390
  • 1
  • 9