Specified key was too long; max key length is 767 bytes
2016-03-14 21:29
393 查看
使用flask-sqlalchemy操作mysql数据库,ubuntu14.04,报错:
Specified key was too long; max key length is 767 bytes
原因:
查看数据库的character_set_database是utf8mb4
可以看出数据库使用的是utf8mb4字符,一个utf8mb4字符使用4btyes,限制最大bytes数为767bytes,
除以4,等于191.75,所以最大是191个string
代码中使用了
name = db.Column(db.String(200), nullable=False, default='', unique=True)
超过了191,所以报上述错误;
参考:
http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes
Specified key was too long; max key length is 767 bytes
原因:
查看数据库的character_set_database是utf8mb4
可以看出数据库使用的是utf8mb4字符,一个utf8mb4字符使用4btyes,限制最大bytes数为767bytes,
除以4,等于191.75,所以最大是191个string
代码中使用了
name = db.Column(db.String(200), nullable=False, default='', unique=True)
超过了191,所以报上述错误;
参考:
http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes
相关文章推荐
- CodeForces 219D-H - Choosing Capital for Treeland-树DP
- Windows7 C盘 不能新建文件 修改权限 更改用户
- 网页分块设计
- Jquery validate配置项
- 机器学习实践中的 7 种常见错误
- Collection,List,Set和Map用法和区别
- The difference between Python __init__ and __new__
- Yii2.0 数据库查询方法
- Emgu在VS2012中的安装和配置
- ListView的一些常用设置
- bpel 测试遇到“The content of the body cannot be displayed in the form view. Please switch to the source”
- 2639: 矩形计算|二维莫队
- python之父之语 import this
- 获取string的长度
- 自学MVC开发基础
- 界面跳转
- 复制粘贴出来的悲剧----spring实现文件下载和HttpStatus.CREATED
- 图论相关算法理解和总结
- SpringMVC——注解的使用与结果跳转方式
- 自定义View实现正好显示文本