【问题标题】:rails with postgresl database "role postgres does not exist"带有postgresql数据库的rails“角色postgres不存在”
【发布时间】:2014-11-24 19:14:09
【问题描述】:

我在我的 rails 应用程序中安装了 postgres,但我无法创建任何角色。 对于su - postgrespsql -d template1 -U postgres 我得到psql:FATAL role "postgres" does exist 我也跑了createuser -s -U $USER

我做错了什么? 谢谢!

【问题讨论】:

  • 你是如何安装 PostgreSQL 的?您使用的是哪个操作系统?
  • 哪个是你的database.yml
  • default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: 5 development: <<: *default database: pigo_development
  • 我使用的是 ubuntu 14,并使用 sudo apt-get install postgresql 安装了 postgresql
  • 你已经运行service postgresql initdb了吗?

标签: ruby-on-rails postgresql


【解决方案1】:

以下是已回答问题的列表:

根据您安装 PostgeSQL 的方式,您可能没有postgres 角色。例如,在我的机器上,当我通过 Homebrew 安装 PostgreSQL 时,安装会创建默认用户作为当前登录用户,而不是 postgres

因此,登录我必须使用

psql -U <myuser> -h localhost

而不是

psql -U postgres -h localhost

你可能会得到错误

psql: FATAL:  database "<user>" does not exist

在这种情况下,请按照this topic 中的说明创建用户数据库。

【讨论】:

  • 感谢您提供的信息,我尝试使用 sudo -i -u postgres createuser --interactive。它提示新角色是否应该是超级用户?我按 y 然后我得到psql: FATAL: role "bogdan" does not exist
  • sudo -i -u postgres 来自哪里?我从来没有提到过。请阅读我的答案和相关答案。
猜你喜欢
  • 2011-12-13
  • 2013-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-28
相关资源
最近更新 更多