django migrate 報錯(You have an error in your SQL syntax)

問題

django migrate 報錯

  • 在本地執行的時候發現沒問題,到了服務器就不行了,報錯

    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的版本,我選擇的是更換Django版本

    pip install mysqlclient==1.4.2
    pip install Django==2.0.5

本文鏈接:django migrate 報錯

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章