Error during Django “Running migrations”: django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')

丶灬走出姿态 提交于 2019-12-02 01:59:45

问题


My Django project is connect to the remote MySQL database.

After I created all the model classes in Django, I tried

python manage.py makemigrations

Everything is fine. Then I entered

python manage.py migrate

Then an error occurred during "Running migrations:", "Applying event.0002_auto_20150904_2141..."

Error code:

django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')

Does anyone know what might cause this error? I followed the exact procedures in the official Django tutorial.


回答1:


Please do this :
1- Install new fresh of mySQL server first.
2- Create new db
3- Config in django settings like this :

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'db_name',
    'USER': 'root',
    'PASSWORD': 'db_pass',
    'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
    'PORT': '3306',
    'OPTIONS': {"init_command": "SET storage_engine=MyISAM"},
}

4- Re-run syncdb
5- Re-run migrate
I hope this work



来源:https://stackoverflow.com/questions/32399831/error-during-django-running-migrations-django-db-utils-operationalerror-201

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