[英]Error during Django “Running migrations”: django.db.utils.OperationalError: (2013, 'Lost connection to MySQL server during query')
My Django project is connect to the remote MySQL database. 我的Django项目已连接到远程MySQL数据库。
After I created all the model classes in Django, I tried 在Django中创建所有模型类之后,我尝试了
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..." 然后在“正在运行的迁移:”,“正在应用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. 我按照官方Django教程中的确切步骤进行操作。
Please do this : 请这样做:
1- Install new fresh of mySQL server first. 1-首先安装新的mySQL服务器。
2- Create new db 2-创建新的数据库
3- Config in django settings like this : 3-在Django设置中进行配置,如下所示:
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 4-重新运行syncdb
5- Re-run migrate 5-重新运行迁移
I hope this work 我希望这项工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.