ruby-on-rails - rake 中止! PG::ConnectionBad:fe_sendauth:未提供密码任务:TOP => db:migrate(通过使用 --trace 运行任务查看完整跟踪)

标签 ruby-on-rails postgresql heroku ruby-on-rails-4

我在尝试 rake db:migrate 时得到以下结果

rake aborted!
PG::ConnectionBad: fe_sendauth: no password supplied

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

我在访问本地主机时也收到了类似的消息

fe_sendauth: no password supplied

我的 rails server 和 rails console 也不行

我一直在尝试一些事情,这就是我的 gemfile 目前的样子:

source 'https://rubygems.org'
ruby '2.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'devise'


gem 'pg'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end


group :production do
  gem 'rails_12factor'
end

和我的database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: myapp_development
  pool: 5
  username: myapp
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: myapp_test
  pool: 5
  username: myapp
  password:

production:
  adapter: postgresql
  encoding: unicode
  database: myapp_production
  pool: 5
  username: myapp
  password:

问题是什么?似乎要在本地访问我的 postgres 表我需要某种密码?我的应用程序在通过 Heroku 运行时运行良好。所以我只是打开 Heroku,我可以按照我的应用程序的预期提交新链接和帖子,但它不会在本地运行。

最佳答案

对于您的本地计算机,在 database.ymltestdevelopment 部分下,您应该更改 username到您登录的用户名。 Rails 生成器使其与应用程序名称相同 - 这将不起作用。对于生产来说,这无关紧要,因为它在 Heroku 上运行,并且它们会在您部署时自动更改该设置。

关于ruby-on-rails - rake 中止! PG::ConnectionBad:fe_sendauth:未提供密码任务:TOP => db:migrate(通过使用 --trace 运行任务查看完整跟踪),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22704025/

相关文章:

ruby-on-rails - 使用 Koala 从应用程序发布到用户页面的墙上

使用 ruby​​mine 后 ruby​​gem pg 未安装

postgresql - Postgres 查询适用于 9.0 但不适用于 9.2

ruby-on-rails - 您的 Gemfile 不止一次列出了 gem。可能会导致错误

scala - 对象类型安全不是包的成员

ruby-on-rails - 在 Heroku 上调试 Paperclip

ruby-on-rails - 预加载模型关联查找

ruby-on-rails - `load_missing_constant' : Circular dependency detected while autoloading constant ApplicationRecord (RuntimeError)

ruby-on-rails - 如何在 Ruby 中生成随机日期?

sql - 优化大型表上的 SQL 连接