PG ::错误:错误:关系schema_migrations的权限被拒绝 [英] PG::Error: ERROR: permission denied for relation schema_migrations

查看:103
本文介绍了PG ::错误:错误:关系schema_migrations的权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定为什么会遇到此错误。我已经正确设置了postgresql,只是运行了一个迁移,然后耙db:migrate,然后出现标题错误。

Not sure why I'm running into this error. I've setup postgresql properly, just ran a migration and then rake db:migrate and I'm getting the title error.

这是我的:

database.yml

database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: my_blog_development
  pool: 5
  username: my_blog
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: my_blog_test
  pool: 5
  username: my_blog
  password:

production:
  adapter: postgresql
  encoding: unicode
  database: my_blog_production
  pool: 5
  username: my_blog
  password:

完全错误:

[my_blog]$rake db:migrate
rake aborted!
PG::Error: ERROR:  permission denied for relation schema_migrations
: SELECT "schema_migrations".* FROM "schema_migrations"
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:739:in `exec'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:739:in `exec_no_cache'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql/database_statements.rb:138:in `block in exec_query'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:425:in `block in log'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0.rc1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:420:in `log'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in `exec_query'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:856:in `select'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/abstract/database_statements.rb:24:in `select_all'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/querying.rb:36:in `find_by_sql'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/relation.rb:561:in `exec_queries'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/relation.rb:447:in `load'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/relation.rb:196:in `to_a'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/relation/delegation.rb:12:in `map'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:770:in `get_all_versions'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:928:in `migrated'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:933:in `ran?'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:910:in `block in runnable'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:910:in `reject'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:910:in `runnable'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:887:in `migrate'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:747:in `up'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:725:in `migrate'
/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-4.0.0.rc1/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/usr/local/rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:migrate


推荐答案

似乎您还没有设置您的psql角色(或用户,它们在postgres中非常相似)。另外,我不确定postgres是否会抱怨没有登录角色并且没有密码(因为您必须告诉postgres用户/角色可以登录)

It would seem that you haven't set up your psql role (or user, they're very similar in postgres). Also, I'm not sure if postgres would complain about having a role and no password for login (as you have to tell postgres that a user/role is allowed to login)

如果以root用户作为root用户输入psql,则可以通过以下操作很好地设置角色:

if you enter psql as the root db user, you can set up roles nicely by doing:

create role my_blog with login password '' createdb;

此外,为了方便起见,如果您使用的是postgres,则可能值得安装 Postgres应用,通常不需要密码即可进入管理员,这使postgres的管理更加容易,这使您可以轻松查看/如果您遇到困难,请放下桌子。 这是一个不错的列表,用于从psql cli管理postgres。

Also, just for convenience, if you're using postgres, it could be worth installing the Postgres app, it generally makes administration of postgres a lot easier by not needing passwords to get into admin which would allow you to easily see/drop tables if you ever get stuck. Here's a nice list of some commands for administering postgres from the psql cli

这篇关于PG ::错误:错误:关系schema_migrations的权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆