Rails: PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations

前端 未结 6 678
慢半拍i
慢半拍i 2021-02-07 01:48

I\'m trying to create the database in Rails. In Postgres I see the development and test database, however, I\'m getting a permissions error. I\'ve tried to follow this link, did

6条回答
  •  醉话见心
    2021-02-07 02:33

    Try listing your tables to see who the owner is. In my case, I had imported data via psql < dump.sql and all the imported tables were owned by postgres instead of my user.

    To check this, start psql and enter the command \dt within your database. Look for the following line:

    public | schema_migrations | table | postgres
    

    Not good! It's owned by postgres and you'll need to fix that:

    1. You can use @ddreliv's solution here to reassign the owner of every table, or
    2. if you have a dump, simply drop the database and re-import it with the proper user. For example, use sudo -u my_user psql < dump.sql instead of sudo -u postgres psql < dump.sql.

提交回复
热议问题