Rails:致命-用户的对等身份验证失败(PG::错误)

我正在Ubuntu 11.10和RubyMine上运行我的开发

这是我的数据库开发设置。yml:RubyMine为我创建的数据库

开发:
适配器:postgresql
编码:unicode
数据库:mydb_开发
游泳池:5
用户名:myuser
密码:

当我尝试运行应用程序时,我在下面得到了这个错误,似乎我还没有创建“项目”用户,但是,我如何创建一个用户并在postgres中授予它一个数据库?如果这是一个问题,那么在Ubuntu中推荐使用什么工具来完成这项任务呢?如果这不是问题所在,请给出建议

退出
/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/postgresql\u adapter.rb:1194:“初始化”中:致命:用户“项目”的对等身份验证失败(PG::Error)
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/postgresql\u adapter.rb:1194:in'new'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/postgresql\u adapter.rb:1194:in'connect'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/postgresql\u adapter.rb:329:in'initialize'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/postgresql\u adapter.rb:28:in'new'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/postgresql\u adapter.rb:28:in`postgresql\u connection'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:303:in'new\u connection'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:313:在“签出新连接”中
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:237:在“签出中的块(2个级别)”中
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:232:in'loop'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:232:“签出中的块”中
from/home/sam/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in'mon_synchronize'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:229:in'checkout'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:95:in'connection'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/connection\u adapters/abstract/connection\u pool.rb:398:在“检索连接”中
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u-record/connection\u-adapters/abstract/connection\u-specification.rb:168:in'retrieve\u-connection'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u-record/connection\u-adapters/abstract/connection\u-specification.rb:142:in'connection'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active\u record/model\u schema.rb:308:in'clear\u cache!'
from/home/sam/.rvm/gems/[email protected]/gems/activerecord-3.2.3/lib/active_record/railtie.rb:91:in`block(2层)in<类别:铁轨>'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u-support/callbacks.rb:418:in``运行\准备\ 404863399 \回调'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u support/callbacks.rb:405:in`\u run\u callback'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u-support/callbacks.rb:385:在“运行\u准备\u回调”中
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u support/callbacks.rb:81:in'run\u callbacks'
from/home/sam/.rvm/gems/[email protected]/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:74:in'prepare!'
from/home/sam/.rvm/gems/[email protected]/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:48:in'prepare!'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/application/finisher.rb:47:in`block in<模块:修整器>'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/initializable.rb:30:in'instance_exec'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/initializable.rb:30:in'run'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/initializable.rb:55:in`block in run_initializers'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/initializable.rb:54:in'each'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/initializable.rb:54:in'run_initializers'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/application.rb:136:in'initialize!'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in'method_missing'
from/home/sam/RubymineProjects/project/config/environment.rb:5:in`<顶部(必需)>'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u-support/dependencies.rb:251:in'require'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u support/dependencies.rb:251:in'block in require'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u-support/dependencies.rb:236:in'load\u-dependency'
from/home/sam/.rvm/gems/[email protected]/gems/activesupport-3.2.3/lib/active\u-support/dependencies.rb:251:in'require'
from/home/sam/RubymineProjects/project/config.ru:4:in`block in<主>'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/builder.rb:51:in'instance_eval'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/builder.rb:51:in'initialize'
from/home/sam/RubymineProjects/project/config.ru:1:in'new'
from/home/sam/RubymineProjects/project/config.ru:1:in`<主>'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/builder.rb:40:in'eval'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/builder.rb:40:in'parse_file'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/server.rb:200:in'app'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in'app'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/server.rb:301:in'wrapp'
from/home/sam/.rvm/gems/[email protected]/gems/rack-1.4.1/lib/rack/server.rb:252:in'start'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in'start'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/commands.rb:55:in`block in<顶部(必需)>'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/commands.rb:50:in'tap'
from/home/sam/.rvm/gems/[email protected]/gems/railties-3.2.3/lib/rails/commands.rb:50:in`<顶部(必需)>'
from/home/sam/RubymineProjects/project/script/rails:6:in'require'
from/home/sam/RubymineProjects/project/script/rails:6:in`<顶部(必需)>'
from-e:1:in“load”
from-e:1:in`<主>'
进程已完成,退出代码为1

如果您在服务器上安装了postresql,那么只需将host:localhost安装到database.yml,我通常会将它放在pool:5的位置。否则,如果不是localhost,一定要告诉该应用程序在哪里可以找到它的数据库

开发:
适配器:postgresql
编码:unicode
数据库:kickrstack_开发
主机:本地主机
游泳池:5
用户名:kickrstack
密码:secret

通过创建数据库并将所有权分配给应用程序的用户以建立连接,确保用户凭据设置正确。要在postgresql 9中创建新用户,请运行:

sudo-u postgres psql

设置postgresql用户密码如果您没有,它只是反斜杠密码

postgres=\password

创建新用户和密码以及用户的新数据库:

postgres=#创建用户“guy_on_stackoverflow”,密码为“keepitonthedl”;
postgres=#创建数据库“dcaclab_开发”所有者“guy_on_stackoverflow”;

现在,在确认创建数据库、用户、密码并设置这些权限后,更新database.yml文件。不要忘记主机:localhost

发表评论