Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FATAL: database "postgres" does not exist

Weird error. All help appreciated.

Here's my database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: app_development
  pool: 5
  username: username
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: app_test
  pool: 5
  username: username
  password:

production:
  adapter: postgresql
  encoding: unicode
  database: app_production
  pool: 5
  username: username
  password:

When I create the databases manually and try to use them, for example rake db:test:preare I get the following error:

FATAL:  database "postgres" does not exist

When I try to drop the databases I get the following errors:

Couldn't drop app_development : #<PG::Error: FATAL:  database "postgres" does not exist
>
Couldn't drop app_test : #<PG::Error: FATAL:  database "postgres" does not exist
>
Couldn't drop app_production : #<PG::Error: FATAL:  database "postgres" does not exist

If I try to create the databases through with rake db:create:all I get the following errors:

app_development already exists
app_test already exists
app_production already exists

So it appears that my database.yml is ok. But for some reason it's looking for a database called postgres when that's not what's in my database.yml.

Any help appreciated.

EDIT:

Here is more from the trace of rake:

Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"app_production", "pool"=>5, "username"=>"username", "password"=>nil}

like image 444
user1432031 Avatar asked Jun 02 '12 06:06

user1432031


1 Answers

[Mac OS X] I've never had any problem with PostGreSQL while using Linux. However, I started working with a MacBook and got the same error as you. So... Probably this is not the solution you were expecting for, but this one app solved all my headaches. I just wanted to share it with you guys.

http://postgresapp.com/

like image 78
Flavio Wuensche Avatar answered Sep 23 '22 09:09

Flavio Wuensche