gpt4 book ai didi

ruby-on-rails - Windows 上的 PostgreSQL Ruby on Rails 5 - fe_sendauth : no password supplied

转载 作者:行者123 更新时间:2023-11-29 13:19:23 24 4
gpt4 key购买 nike

我正在关注 this guide使用 Postgres 设置 Rails 项目。

到目前为止,我已经安装了 postgress 和 Heroku toolbelt 并完成了以下操作:

  1. 使用我的 heroku 凭据登录
  2. 使用 postgres 创建了一个 rails 项目 rails new myapp --database=postgresq
  3. 默认的 database.yml 文件如下所示:

    default: &default
    adapter: postgresql
    encoding: unicode
    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

    development:
    <<: *default
    database: myapp_development

    test:
    <<: *default
    database: myapp_test

    production:
    <<: *default
    database: myapp_production
    username: myapp
    password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>
  4. 为主页创建 Controller rails g controller welcome

  5. 创建了 index.html.erb 并添加了路由。 root 'welcome#index'

然后当我运行服务器时,转到 localhost:3000 并得到以下错误PG::ConnectionBad(fe_sendauth:未提供密码):

database.yml 文件或 postgres 的安装和设置有问题吗?

最佳答案

在config/database.yml中,在default:&default下,添加:

 host: localhost
username: postgres
password: (the password you created during postgresql installation goes here)
port: 5432

然后在你的终结器中运行rake db:create:all(如果你在这里遇到同样的问题不用担心)然后运行rake db:migrate,重启您的 Rails 服务器和您的应用程序现在应该可以工作了。

附言我注意到这个问题是一年多前提出的,而您当时已经想出了解决方案。但我将这个解决方案放在这里是为了任何可能遇到同样问题的人,因为我两天前遇到了这个问题,我花了一些时间来找出适合我的解决方案。

关于ruby-on-rails - Windows 上的 PostgreSQL Ruby on Rails 5 - fe_sendauth : no password supplied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44455818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com