0
0

More than 3 years have passed since last update.

django.db.utils.ProgrammingError: permission denied for table django_migrationsの対処法

Last updated at Posted at 2020-01-08

django.db.utils.ProgrammingError: permission denied for table django_migrationsのエラーの対処に苦戦したので書いておこうと思います。

このエラーが出たときpostgresqlのdjango移行を実行中に、接続ファイルで使用されているpostgresqlのユーザーに対して権限設定がなされてないことが原因みたいです。なのでpostgresqlのユーザーに権限を持たせようと思います。

コマンドからpsql -U postgresでpostgresにログインします。

>psql -U postgres

ユーザ postgres のパスワード:
psql (12.1)
"help"でヘルプを表示します。

postgres=#

次に使用したいデーターベースにログインします。(database nameは使用したいデータベースを入れてください。)

postgres=# ¥c database name
データベース"database name"にユーザ"postgres"として接続しました。
database name=#

そして権限を持たせるために3つのコードを入力します。(usernameは使用しようとしているユーザ名に書き換えてください。)

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to username;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to username;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to username;

これでpostgresqlのユーザーに対して権限を持たせることができました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0