Specified key was too long; max key length is 767 bytes解决办法
Posted on 2018-02-11 15:59 古城山人 阅读(875) 评论(0) 收藏 举报ElasicSearch关联的mysql表,插入数据时会有以下提示
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
原因分析:
MySQL的varchar主键只支持不超过767个字节,需要将mysql的字符编码设置为utf8mb4
- 第一步,输入以下命令打开编辑界面:
```
vi /etc/my.cnf
```
```
innodb_file_format=barracuda
innodb_file_per_table=true
innodb_large_prefix=true
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_allowed_packet=500M
```
- 第二步,建表语句添加
```
ROW_FORMAT=DYNAMIC
```
浙公网安备 33010602011771号