django python manage.py migrate 后报错字段长度超了 django.db.utils.OperationalError: (1118 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535.

 

现象:

在models.py 将CharField字段的maxlength=修改后,执行ython manage.py migrate  报错django.db.utils.OperationalError: (1118 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')

我的触发操作 :

models.CharField(max_length=5120 改为  models.CharField(max_length=8192  然后就开始报错,再改回去5120仍然报错 ,无法恢复。

storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')

django.db.utils.OperationalError: (1118, 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes
storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')

报错

django.db.utils.OperationalError: (1118, 'Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes
storage overhead, check the manual. You have to change some columns to TEXT or BLOBs')

 

 解决方案:

找到最近改的CharField 字段,maxlength 长度超过CharField 允许值“”的修正后,将之前makemigrations生成的临时缓存文件删除,再更改字段即可。

步骤一、修改正models.py CharField字段

 然后重新makemigrations   migrate  ? 

你会发现,依然给你抛这个错误

NO NO NO ....

 

步骤二、删除之前CharField不支持的maxlength时, python manage.py makemigrations 生成的 项目名/migrations/xxxxx.py 字段变更记录文件

 步骤三、 再次重新python manage.py makemigrations 生成字段变动文件python manage.py migrate 向数据库提交成功!!!

 

 

 

 

 

发现:我的models.CharField(max_length 最多支持7159  ,7160就会提交失败了,这个值哪来的呢? 

看了这个链接也没有搞明白,朋友圈里大佬指教指教吧.....

https://blog.csdn.net/yinjinshui/article/details/102496340

我的数据库

复制代码
mysql>  show create database monitor_test;
+--------------+--------------------------------------------------------------------------+
| Database     | Create Database                                                          |
+--------------+--------------------------------------------------------------------------+
| monitor_test | CREATE DATABASE `monitor_test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+--------------+--------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
复制代码

 

posted on   zhangmingda  阅读(388)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示