美文网首页源码首页推荐
Specified key '%s' was t

Specified key '%s' was t

作者: holly_wang_王小飞 | 来源:发表于2016-11-15 15:04 被阅读22次

    出现这个错误是在创建索引的时候,原因所选字段的长度超出了可以创建索引的最大长度,InnoDB是767字节,但是有时候明明所选字段的长度很小比如 255 明显比这个小 为什么会报错呢,原来 所选字段当时UTF8编码的时候需要乘以3 UTF8mb4的时候需要乘以4,MySQL reserves 3 bytes per UTF8 character 官网地址mysql

    Paste_Image.png

    让然也可以修改限制从767 bytes (up to 3072 bytes). 在my.cnf文件中

    [mysqld]
    innodb_file_format=barracuda
    innodb_file_per_table=1
    innodb_large_prefix=1
    init_connect='SET collation_connection = utf8mb4_unicode_ci'
    init_connect='SET NAMES utf8mb4'
    character-set-server=utf8mb4collation-server=utf8mb4_unicode_ci

    主要是这两项
    innodb_file_format=barracuda
    and innodb_file_per_table=true
    .

    767 up to 3072

    相关文章

      网友评论

        本文标题:Specified key '%s' was t

        本文链接:https://www.haomeiwen.com/subject/nngkpttx.html