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

The solution to the 1071 error in mysql

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

Share

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

This article mainly introduces the solution to the 1071 error in mysql, which is very detailed and has a certain reference value. Interested friends must finish reading it!

Mysql has a 1071 error solution: the problem is caused by the length of the key value field is too long, mysql supports database forms the maximum length of a key value can not exceed 767 bytes, if the length is changed to 1071, there is no problem, or do not use the utf-8 format.

The solution to a 1071 error in mysql:

The problem is caused by the long length of the key value field. Mysql supports that the maximum length of a key value in a database form cannot exceed 767 bytes, beyond which an error is reported (see title name). In general, there is no key value field whose length exceeds that length. However, it should be noted that with the acceleration of globalization, the trend of database tables using UTF-8 format is becoming more and more obvious, which leads to a double increase in the length of varchar type fields, which is prone to the above problems.

Suppose the following table definition exists:

Create table test (name varchar (256) not null primary key, age int unsigned not null) engine = InnoDB

When the table is created in UTF-8 format, the problem appears as shown in the title. The key reason is that UTF-8 uses variable-length encoding, and it is possible to use up to 3 bytes to represent 1 symbol. So for the name field in the above table, the actual length exceeds 767 bytes to 768 bytes, and the problem arises. There is no problem if you change the length to 255 (767 prime 3) or not using the utf-8 format.

The above is all the contents of the solution to the 1071 error in mysql. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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: 0

*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