2016-07-08 22 views
4

私はRailsでデータベースを作成しようとしています。 postgresでは、私は開発とテストのデータベースを参照してください、しかし、私はパーミッションエラーを取得しています。私はこのリンクに従おうとしましたが、私のために働かなかったのです。PG :: InsufficientPrivilege:ERROR:関係schema_migrationsの権限が拒否されましたrake db:create

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

Rails: permission denied for relation schema_migrations

default: &default 
    adapter: postgresql 
    encoding: unicode 
    pool: 5 
    host: localhost 
    username: root 
    password: 

development: 
    <<: *default 
    database: svp-chicago_development 

私はpostgresのにログインし、これらのコマンドをしました。

psql postgres 
CREATE USER root 
CREATE DATABASE svp-chicago_development 
GRANT ALL PRIVILEGES ON DATABASE svp-chicago_development to root 
ALTER DATABASE svp-chicago_development OWNER TO root 

私は\listのデータベースを参照してください。

+0

パスワードの可能性があります。 'root'ユーザをパスワードで作成して' config/database.yml'ファイルに入れてみてください。 –

答えて

5

userの場合はpasswordを作成していないようです。次のようにパスワードを作成してください:

CREATE USER root WITH PASSWORD 'your_new_password'; 
CREATE DATABASE svp-chicago_development; 
GRANT ALL PRIVILEGES ON DATABASE svp-chicago_development to root; 
ALTER DATABASE svp-chicago_development OWNER TO root; 
+1

私はこれをして、私のポストグルはこの同じエラーを与え続ける。あなたは[リンク](http://stackoverflow.com/questions/41424654/postgres-permission-denied-for-relation-schema-migrations)を見てください。 –

6

私は同じ問題を抱えていましたが、私は役割に「スーパーユーザー」を追加して解決しました。

まず、ユーザーとその特権をリストします。上記のコマンドに従った場合、rootユーザーは「スーパーユーザー」属性を持っていません。

postgres=# \du 
            List of roles 
Role name |       Attributes       | Member of 
-----------+------------------------------------------------------------+----------- 
other  | Superuser, Create role, Create DB, Replication, Bypass RLS | {} 
root  |               | {} 

次に、「スーパーユーザー」になるようにrootをアップグレードします。

postgres=# ALTER USER root WITH SUPERUSER; 
ALTER ROLE 

また、ユーザーとその特権をリストします。 rootには "Superuser"があります。

postgres=# \du 
           List of roles 
Role name |       Attributes       | Member of 
-----------+------------------------------------------------------------+----------- 
other  | Superuser, Create role, Create DB, Replication, Bypass RLS | {} 
root  | Superuser             | {} 

希望します。

+0

これは私の問題を解決するのを助けました。ありがとうございました。 – iamse7en

関連する問題