Rails postgres 使用 --database=postgresql 时的默认数据库用户

Mar*_*ear 8 postgresql ruby-on-rails

我觉得我应该知道这一点,但我不知道!

--database=postgresql使用database.yml创建新的rails应用程序时,如下所示:

...
default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see Rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: big_bustas_development
...
Run Code Online (Sandbox Code Playgroud)

现在我可以执行各种rails db:create...迁移...等操作,而无需显式配置数据库用户和密码。Rails 使用什么 postgres 凭据来完成此操作?

小智 9

PostgreSQL 默认使用您的操作系统用户名。PostgreSQL 的默认身份验证模式设置为ident。阅读本文和/或文档以获取更多信息。