我正在尝试在Cloud9的Rails应用程序中设置postgres数据库。
我遵循了这里的说明:https://docs.c9.io/setting_up_postgresql.html并设置了一个名为cc_database的数据库。
我的database.yml文件如下所示:
development:
adapter: postgresql
encoding: SQL_ASCII
database: cc_database
pool: 5
username: postgres
password: password当我运行rake :setup时,我得到以下错误:
PG::ConnectionBad: FATAL: Peer authentication failed for user "postgres"我对这一切都是新手,所以任何建议都将不胜感激。
发布于 2014-12-30 22:34:17
执行以下步骤:
$ sudo service postgresql start $ sudo sudo -u postgres psql postgres=#创建用户用户名超级用户密码' PASSWORD ';postgres=# \q
$ echo "export USERNAME=username“源~/.profile $ echo "export PASSWORD=password”源~/.profile $ >> ~/.profile
我在cloud9上的rails 4.2.0的database.yml:
默认:默认适配器: postgresql编码:Unicode池:5用户名:<%= ENV'USERNAME‘%>密码:<%= ENV'PASSWORD’%> host:<%= ENV‘in’%>开发:<<:*默认数据库: sample_app_development test:<<:*默认数据库: sample_app_test production:<<:*默认数据库: gem pg in Gemfile并安装:
gem 'pg','~> 0.18.2'
$ bundle安装
postgres=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = ' template1 ';postgres=# DROP DATABASE template1;postgres=# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';postgres=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';postgres=# \c template1 postgres=# VACUUM FREEZE;postgres=# \q
捆绑包exec rake数据库:创建
发布于 2015-04-01 06:55:18
cloud9中的postgresql被设置为在本地主机连接时与对等体进行身份验证。因此,快速解决方案是将database.yaml中的用户更改为当前用户。在我的例子中,用户名是ubuntu。要查看当前用户,请使用以下命令
$ echo $USER
因此,终端中的命令列表是。
$ sudo su - postgres
$ createuser ubuntu -dslP
$ Enter password for new role: **same password from your yaml file**
$ Enter it again:将您的yaml文件设置如下
development:
adapter: postgresql
encoding: SQL_ASCII
database: cc_database
pool: 5
username: ubuntu
password: password现在你可以运行
rake db:create
rake db:migrate发布于 2015-05-15 01:49:16
使用用户名"ubuntu“,密码为空。我的database.yml看起来像这样:
开发:
适配器: postgresql
编码: unicode
数据库: myflix_development
池:5个
用户名: ubuntu
密码:
测试:
适配器: postgresql
编码: unicode
数据库: myflix_test
池:5个
用户名: ubuntu
密码:
如果它随后报告密码错误,请尝试使用Cloud9的说明更改密码:
在命令行中,键入:sudo sudo -u postgres psql
postgres=# \password
输入新密码:leave it blank and press enter
再次输入:leave it blank and press enter
postgres=# \q
我对此还是个新手。希望这能起作用!
https://stackoverflow.com/questions/26545746
复制相似问题