问题

django migrate 报错

  • 在本地执行的时候发现没问题,到了服务器就不行了,报错
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Operations to perform:
Apply all migrations: bank_detections
Running migrations:
Traceback (most recent call last):
File "/var/www/bank_detection/venv_bank/lib/python3.5/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/var/www/bank_detection/venv_bank/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 71, in execute
return self.cursor.execute(query, args)
File "/var/www/bank_detection/venv_bank/lib/python3.5/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/var/www/bank_detection/venv_bank/lib/python3.5/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/var/www/bank_detection/venv_bank/lib/python3.5/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1")

解决

更换Django的版本

  • MySQL5.5并不支持Django2.1生成的这种SQL语句,更换Django的版本或者是换MySQL的版本
1
2
pip install mysqlclient==1.4.2
pip install Django==2.0.5