如何为本地Rails项目设置Postgres数据库? [英] How to set up Postgres database for local Rails project?

查看:135
本文介绍了如何为本地Rails项目设置Postgres数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近有一台新机器,现在想从Github从事我的项目。我很好奇如何在本地计算机上正确设置Postgres数据库。我安装了 postgresql pgadmin3 libpq-dev Ubuntu(12.04)。

I recently got a new machine and would now like to work on my projects from Github. I'm curious as to how to properly set up the Postgres database on my local machine. I have postgresql, pgadmin3 and libpq-dev installed on Ubuntu (12.04).

我下拉项目:

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

并运行:

bundle

我跑步时:

rake db:create&& rake db:schema:load

我收到此错误:

rake db:create && rake db:schema:load
FATAL:  password authentication failed for user "cnh"
FATAL:  password authentication failed for user "cnh"
....

config / database.yml 文件如下所示:

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

test:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: cnh_test
  pool: 5
  username: cnh
  password: cnh

production:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: cnh_production
  pool: 5
  username: cnh
  password: cnh

设置Postgres数据库的正确方法是什么,以便我可以在本地计算机上运行此项目?

What's the proper way to set up the Postgres database so I can run this project on my local machine?

现在,当我启动Rails服务器时我得到:

Right now when I start the Rails server I get:

推荐答案

首先,安装postgresql

firstly, install postgresql

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update

#now install postgresql
sudo apt-get install postgresql-9.1 libpq-dev



在psql中创建新用户

create a new user in psql

sudo su postgres
createuser user_name #Shall the new role be a superuser? (y/n) y



Gemfile

Gemfile

gem 'pg'

捆绑安装

development:
  adapter: postgresql
  database: app_development
  pool: 5
  username: user_name
  password:

这篇关于如何为本地Rails项目设置Postgres数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆