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

后端 未结 1 636
庸人自扰
庸人自扰 2021-01-23 01:58

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
         


        
1条回答
  •  悲&欢浪女
    2021-01-23 02:04

    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

    0 讨论(0)
提交回复
热议问题