Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql index is too long 1071-max key length is 767 byte

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

problem

Create table: Specified key was too long; max key length is 767 bytes

Reason

The database table is encoded by utf8, in which the column of varchar (255) has a unique key index.

By default, the index of a single column in mysql cannot exceed 767bits (there may be differences between different versions)

Therefore, under utf8 character encoding, 255cm 3 byte exceeds the limit.

Solve

1 using the innodb engine

2 enable the innodb_large_prefix option to extend the constraint to 3072byte

3 recreate the database

My.cnf configuration:

Default-storage-engine=INNODB

Innodb_large_prefix=on

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 212

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report