在ubuntu 16.04上重新安装系统,当第一次尝试运行python manage.py makemigrations
时出现以下错误:
django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")
我的django数据库设置是:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'license_portal',
'USER': '****',
'PASSWORD': '****',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {
"init_command": "SET storage_engine=MyISAM",
},
},
}
图书馆:
(mmslic) ➜ mmsLicenseServer git:(master) ✗ pip freeze
Django==1.8.12
django-admin-bootstrapped==2.5.7
django-bootstrap3==7.0.1
MySQL-python==1.2.5
mysqlclient==1.3.7
requests==2.9.1
(mmslic) ➜ mmsLicenseServer git:(master) ✗ dpkg -l | grep -i mysql
ii libmysqlclient-dev 5.7.12-0ubuntu1 amd64 MySQL database development files
ii libmysqlclient20:amd64 5.7.12-0ubuntu1 amd64 MySQL database client library
ii libmysqlclient20:i386 5.7.12-0ubuntu1 i386 MySQL database client library
ii libqt4-sql-mysql:i386 4:4.8.7+dfsg-5ubuntu2 i386 Qt 4 MySQL database driver
ii mysql-client-5.7 5.7.12-0ubuntu1 amd64 MySQL database client binaries
ii mysql-client-core-5.7 5.7.12-0ubuntu1 amd64 MySQL database core client binaries
ii mysql-common 5.7.12-0ubuntu1 all MySQL database common files, e.g. /etc/mysql/my.cnf
ii mysql-server 5.7.12-0ubuntu1 all MySQL database server (metapackage depending on the latest version)
ii mysql-server-5.7 5.7.12-0ubuntu1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.7 5.7.12-0ubuntu1
答案 0 :(得分:22)
在努力解决这个问题之后,我发现问题是MySQL 5.7版本的变化。
使用MySQL 5.7,命令SET storage_engine=MyISAM
无法正常工作,所以这就是问题!
正如在MySQL 5.7 documentation使用default_storage_engine
上发现的那样!我的配置变为:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'license_portal',
'USER': '****',
'PASSWORD': '****',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {
"init_command": "SET default_storage_engine=MyISAM",
},
},
}