In Rails, Couldn't create database for {"adapter"=>"postgresql",
Solved!
Solution was simple to update current installed gems.
Another solution to try is set host: localhost
or whatever host you use on development settings on database.yml file.
I installed PG on Mac OS X via Homebrew (I didn't realize it came default in Mac OS X), and had the same problem. I may have made the problem worse by installing the pg gem before installing pg via Homebrew.
I solved this same problem by doing the following:
- Make sure that all binaries are pointing to binaries in Cellar directory (/usr/local/Cellar on Mac OS X)
- Uninstall pg gem
gem uninstall pg
- Reinstall with Homebrew configs
gem install pg -- --with-pg-config=/usr/local/bin/pg_config
(if you created a rails project with pg setup, this is explained in your database.yml config file)
And it worked!
First, you will need to create your user manually in Postgres, while granting privilege of database creation (AKA createdb) for this user.
To do so, first, open Postgres shell prompt
$ sudo -u postgres psql
Create your user
postgres=# create role Your_DB_username with createdb login password 'YOUR_PASSWORD';
Exit from Postgres shell
postgres=# \q
Do whatever db-related rake task:
$ rake db:create
And it will work!