Ruby-on-rails Rake db:reset '用户没有连接权限'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18972829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rake db:reset 'user does not have CONNECT privilege'
提问by Tom Maxwell
So I'm using Heroku Postgres in my Rails app, but I'm not hosting my app on Heroku itself. I used the Active Record connection details from Heroku in my database.yml, and it looks like this:
所以我在我的 Rails 应用程序中使用 Heroku Postgres,但我没有在 Heroku 本身上托管我的应用程序。我在我的 database.yml 中使用了来自 Heroku 的 Active Record 连接详细信息,它看起来像这样:
development:
adapter: postgresql
encoding: unicode
pool: 5
database: [database]
username: [username]
password: [password]
host: ec2-54-227-243-78.compute-1.amazonaws.com
port: 5432
However, now I'm trying to rake db:migrate my app so the database gets all set up with my models. Running that command doesn't do anything, so I tried rake db:resetand I get this:
但是,现在我正在尝试 rake db:migrate 我的应用程序,以便使用我的模型设置数据库。运行该命令并没有做任何事情,所以我试了一下rake db:reset,我得到了这个:
Couldn't drop df2cokjfj0k4vu : #<PG::Error: FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
df2cokjfj0k4vu already exists
-- initialize_schema_migrations_table()
-> 1.3997s
-- assume_migrated_upto_version(20130924040351, ["/home/action/braindb/db/migrate"])
-> 0.0882s
df2cokjfj0k4vu 已经存在
-- initialize_schema_migrations_table()
-> 1.3997s
-- 假设_migrated_upto_version(20130924040351, ["/home/action/braindb/db/migrate"])
-> 0.0882s
Any idea what I'm doing wrong. I'm still pretty new to Rails so sometimes I forget how to get my Postgres database setup properly when migrating hosts.
知道我做错了什么。我对 Rails 还是很陌生,所以有时我会忘记如何在迁移主机时正确设置我的 Postgres 数据库。
回答by luigi7up
Use heroku pg:reset DATABASEinstead as noted in https://devcenter.heroku.com/articles/rake
使用heroku pg:reset DATABASE如指出,而不是https://devcenter.heroku.com/articles/rake
You cannot drop databases in Heroku with rake db:resetbecause user has no privileges.
你不能删除 Heroku 中的数据库,rake db:reset因为用户没有权限。
回答by Nick Veys
You can't drop your PG databaseon Heroku.
你不能在 Heroku 上删除你的 PG 数据库。
回答by user3162553
I recently had this problem and resolved it through the following steps.
我最近遇到了这个问题,并通过以下步骤解决了它。
heroku pg --helpgets the name of commands for using postgresheroku pg:reset DATABASE# resets the dbAnswer the prompt to confirm
heroku pg --help获取使用 postgres 的命令名称heroku pg:reset DATABASE# 重置数据库回答提示以确认
回答by tfantina
Like others I had a similar problem but running pg:resetdid not help: that's where I ran into the user does not have CONNECT privilegeissue.
像其他人一样,我遇到了类似的问题,但跑步pg:reset并没有帮助:这就是我遇到user does not have CONNECT privilege问题的地方。
1) heroku pg:resetyou will be prompted to enter the project name to confirm.
1)heroku pg:reset会提示您输入项目名称进行确认。
2) From Heroku's docsrun heroku rake db:schema:load
2) 从Heroku 的文档运行heroku rake db:schema:load
回答by rattanak
I had the same problem. I fixed it by running:
我有同样的问题。我通过运行修复它:
heroku pg:reset DATABASE
heroku pg:reset DATABASE
(note: must specify DATABASE as above)
(注意:必须如上指定 DATABASE)
回答by user1515295
For one of my apps, upgrading to the first paid tier of a Heroku database seemed to work for me: https://devcenter.heroku.com/articles/upgrade-heroku-postgres-with-pgbackups#provision-new-plan
对于我的一个应用程序,升级到 Heroku 数据库的第一个付费层似乎对我有用:https: //devcenter.heroku.com/articles/upgrade-heroku-postgres-with-pgbackups#provision-new-plan
Reason was that 'heroku pg:info' revealed that I was over my row limit as shown here: Rows: 12392/10000 (Write access revoked)
原因是 'heroku pg:info' 显示我超出了我的行数限制,如下所示:Rows: 12392/10000(已撤销写访问权限)

