Rails: permission denied for relation schema_migrations

北城余情 提交于 2019-12-21 03:48:36

问题


I'm trying to setup a local production environment for a Ruby on Rails web application. I can run the application with rails server command, which gives the development environment.

The production environment I'm trying to set up is purely local and I've followed this tutorial for setting it up with apache 2: https://www.digitalocean.com/community/tutorials/how-to-setup-a-rails-4-app-with-apache-and-passenger-on-centos-6

However when I go to the page of my application I get the following error:

PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations : SELECT "schema_migrations".* FROM "schema_migrations"

in my database.yml I have these settings for development and production:

adapter: postgresql
database: whiteboard
username:
password:
pool: 5
timeout: 5000

I'm not allowed to change these settings, no matter what.

Is there any way to fix this? (if yes, step by step please)


回答1:


It seems you have to create a DB user with all needed privileges on your DB. For example I think you could do the trick by log in your DB console then do something like:

CREATE USER your_new_username WITH PASSWORD 'your_new_password';
CREATE DATABASE whiteboard;
GRANT ALL PRIVILEGES ON DATABASE whiteboard to your_new_username;
ALTER DATABASE whiteboard OWNER TO your_new_username;

Then update you database.yml like this:

adapter: postgresql
database: whiteboard
username: your_new_username
password: your_new_password
pool: 5
timeout: 5000

Hope it helps!



来源:https://stackoverflow.com/questions/33801628/rails-permission-denied-for-relation-schema-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!