django.db.utils.OperationalError: attempt to write a readonly databaseエラー対応
Djangoの管理ユーザを作成しようとすると下記のエラーが発生。
「django.db.utils.OperationalError: attempt to write a readonly database」
「readonly database」から書込み権限が無いと推測できる。
とりあえずググってみた。ありましたね。今回も先人様のお知恵をお借りいたします。
ありがとうございます。
ayahito2828.hatenablog.com
[opc@django project]python3.7 manage.py createsuperuser ユーザー名 (leave blank to use 'opc'): メールアドレス: opc@example.com Password: Password (again): Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 413, in execute 〜エラー内容省略〜 django.db.utils.OperationalError: attempt to write a readonly database [opc@django project]$ [opc@django project]$ chmod 766 db.sqlite3 chmod: changing permissions of ‘db.sqlite3’: Operation not permitted [opc@django project]$ [opc@django project]$ sudo chmod 766 db.sqlite3 [opc@django project]$ python3.7 manage.py createsuperuser ユーザー名 (leave blank to use 'opc'): メールアドレス: opc@example.com Password: Password (again): Superuser created successfully. [opc@django project]$
無事スーパーユーザ作成できました。