加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – PG ::错误:错误:关系schema_migrations的权

发布时间:2020-12-17 02:34:41 所属栏目:百科 来源:网络整理
导读:不知道为什么我遇到这个错误.我正确设置了 postgresql,只是运行了一个迁移,然后rake db:migrate,我得到了标题错误. 这是我的: database.yml的 development: adapter: postgresql encoding: unicode database: my_blog_development pool: 5 username: my_bl
不知道为什么我遇到这个错误.我正确设置了 postgresql,只是运行了一个迁移,然后rake db:migrate,我得到了标题错误.

这是我的:

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允许用户/角色登录)

如果以root用户身份输入psql,则可以通过以下方式很好地设置角色:

create role my_blog with login password '' createdb;

另外,为了方便起见,如果您使用的是postgres,可能值得安装Postgres app,它通常可以通过不需要密码进入管理员来更轻松地管理postgres,这样您就可以轻松查看/删除表格了永远卡住了.用于管理来自psql cli的postgres的一些命令的Here’s a nice list

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读