Connor Leech
Connor Leech

Reputation: 18873

proper way to clone repo I contribute to, postgres error

I'm a contributor to someone else's repository on github. I want to have the project run on my new machine

I pulled the project with:

git clone https://github.com/thebenedict/cowsnhills.git

and then run bundle and it's all gravy, but when I start the server I get the error

PG::ConnectionBad
FATAL: password authentication failed for user "cnh" FATAL: password authentication failed for user "cnh"

My pg gem seems to be installed alright. I used sudo apt-get install libpq-dev and didn't get errors.

If I do git pull origin master it gives me the appropriate "Already up to date"

It has never asked me for my github login credentials though. What can I do to run the server?

EDIT:

Okay I need to setup the postgres database on my local machine, the config/database.yml file looks like this:

development:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: cnh_development
  pool: 5
  username: cnh
  password: cnh

In the terminal I tried:

$ sudo -u postgres psql
psql (9.1.10)
Type "help" for help.

postgres=# create role cnh with createdb login cnh password 'cnh'
postgres-# \q

$ rake db:setup
FATAL:  password authentication failed for user "cnh"
FATAL:  password authentication failed for user "cnh"

What's the postgres command I need to run to set up my database given the above config file?

Upvotes: 1

Views: 1423

Answers (1)

Connor Leech
Connor Leech

Reputation: 18873

okay I'm really happy. I had to create a pg user, create database and update the user's role via

$ sudo -u postgres psql
CREATE USER cnh WITH password 'cnh';
ALTER USER cnh WITH SUPERUSER;
CREATE DATABASE cnh WITH OWNER cnh;
\q
$ sudo service postgresql restart
$ rake db:setup

Upvotes: 2

Related Questions