Setup postgresql for RoR

Updated . Posted . Visible to the public. Repeats.

Assume your database.yml file looks like this:

{: .yaml}
development:
adapter: postgresql
host: localhost
encoding: unicode
database: proj_development
pool: 5
username: proj
password:
template: template0

test:
  adapter:  postgresql
  host:     localhost
  encoding: unicode
  database: proj_test
  pool:     5
  username: proj
  password:
  template: template0

production:
  adapter:  postgresql
  host:     localhost
  encoding: unicode
  database: proj_production
  pool:     5
  username: proj
  password:
  template: template0

First of all you must create postgresql user proj:

sudo su postgres
createuser proj

Then run psql, in postgres shell run:

ALTER ROLE proj CREATEDB;
\q

Update conf file /etc/postgresql/9.3/main/pg_hba.conf:

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

Then restart posrgresql:

sudo service postgresql restart

Then in project directory run:

rake db:create
rake db:migrate

Now it must works well.

konjoot
Last edit
konjoot
Posted by konjoot to wiki (2014-01-06 12:23)