sayth
sayth

Reputation: 7048

Ruby on Rails - db:create:all error

When I am trying to create a new rails app with a postgres db I cannot complete the rake command.

This is what I have done.

sayth@sayth-TravelMate-5740G:~$ sudo -u postgres psql postgres
[sudo] password for sayth: 
psql (9.2.4)
Type "help" for help.

postgres=# create role sayth login createdb;
ERROR:  role "sayth" already exists

postgres=# DROP user sayth;
DROP ROLE
postgres=# create role sayth login createdb;
CREATE ROLE
postgres=# initdb -D /usr/local/pgsql/data
postgres-# \q
sayth@sayth-TravelMate-5740G:~$ 

I have created my rails app with

rails new testapp2 -d postgres

realised after watching Railscast why it didn't work http://railscasts.com/episodes/342-migrating-to-postgresql

So I edited the config/database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: testapp2_development
  pool: 5
  username: sayth
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: testapp2_test
  pool: 5
  username: sayth
  password:

But still rake wont create my database.

sayth@sayth-TravelMate-5740G:~/testapp2$ rake db:create:all
FATAL:  Peer authentication failed for user "testapp2"
...
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"testapp2_production", "pool"=>5, "username"=>"testapp2", "password"=>nil}

Seems I have read a lot and tried anything I have found but unsure what to do.

This command fails as well.

sayth@sayth-TravelMate-5740G:~/testapp2/config$ psql -U postgres
psql: FATAL:  Peer authentication failed for user "postgres"

Upvotes: 0

Views: 583

Answers (1)

Sachin Singh
Sachin Singh

Reputation: 7225

the error is only in creating production database, here you have specified wrong user, 'testapp2' instead of 'sayth'

Upvotes: 1

Related Questions