我最近买了一台新机器,现在想在Github上完成我的项目.我很好奇如何在本地机器上正确设置Postgres数据库.我在Ubuntu(12.04)上安装了postgresqlpgadmin3libpq-dev.

我撤销了这个项目:

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

然后运行:

bundle

当我 run 时:

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数据库的正确方法是什么,这样我就可以在本地机器上运行这个项目了?

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

在此处输入图像描述

推荐答案

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
create a new user in psql
sudo su postgres
createuser user_name #Shall the new role be a superuser? (y/n) y
Gemfile
gem 'pg'

Bundle 安装

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

Postgresql相关问答推荐

使用PGx在围棋中执行多条SQL语句

哪种数据类型是除法的结果?

Select 二维数组中的特定元素PostgreSQL

如何在PostgreSQL中以行值的形式获取列

Postgres 11没有强制执行外键约束?

在插入时创建一个触发器,在PostgreSQL中的另一个表上创建另一个触发器

Prisma:获取连接的活动 Postgresql 模式的名称

空表上的 Postgres 意外行为

@符号在yacc中的函数中是什么意思

如何防止 PDO 将问号解释为占位符?

Nodejs应用程序的node-postgres vs pg-promise

如何使用 pg_dump 或 psql 从 *.sql 恢复 PostgreSQL 表?

从 PostgreSQL 中的时间戳获取日期

Postgres 类似于 SQL Server 中的 CROSS APPLY

使用 PostgreSQL 创建数据透视表

在 Postgresql 中按窗口函数结果过滤

Postgres:为 CAST 失败定义一个默认值?

python postgres 我可以 fetchall() 100 万行吗?

使用 PostgreSQL 进行字母数字排序

从 5 分钟前的表中获取行