django 2.2报mysql 1366

2021/11/0121:33:50django 2.2报mysql 1366已关闭评论浏览:33
  1. 错误打印
  File "/data/mysites/venv/lib/python3.7/site-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/data/mysites/venv/lib/python3.7/site-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1366, '')
  1. 原因及修正
    原因是因为mysql 5.7默认不允许字符为空,此时需要解除严格模式,在数据库配置文件中添加如下配置即可:
sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  • 微信扫码赞助
  • weinxin
  • 支付宝赞助
  • weinxin