我最近买了一台新机器,现在想在 Github 上处理我的项目。我很好奇如何在本地计算机上正确设置 Postgres 数据库。我有postgresql
, pgadmin3
and libpq-dev
安装在 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"
....
The 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 服务器时,我得到:
我在寻找相同答案时遇到了你的问题。我尝试按照 @prasad.surase 给您的说明进行操作。我发现的问题是 ppa 存储库很快就会在 12.04 LTS 上贬值。相反,我找到了这个链接,它确实很有帮助。
Ubuntu 12.04 中用于 Rails 开发的 PostgreSQL 设置 http://linuxrails.blogspot.com/2012/06/postgresql-setup-for-rails-development.html
-
通过包管理器安装 postgresql 和管理工具
sudo apt-get install postgresql libpq-dev phppgadmin pgadmin3
-
以 postgres 用户身份登录到 postgresql 提示符
sudo su postgres -c psql
-
为您的项目创建一个 postgresql 用户
create user username with password 'password';
-
使用与 Ubuntu 用户相同的名称和密码设置 postgres 用户,并使他成为 postgres 超级用户
alter user username superuser;
-
创建开发和测试数据库
create database projectname_development;
create database projectname_test;
-
授予用户对数据库的权限
grant all privileges on database projectname_development to username;
grant all privileges on database projectname_test to username;
结束 postgresql 会话类型\q
更新用户的密码
alter user username with password ‘new password’;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)