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

Why utf8 is not applicable when building Mysql database

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article is mainly about why the construction of Mysql database is not applicable to utf8 content, if you are interested, let's take a look at this article, I believe that after reading the construction of Mysql database why not apply utf8 to you more or less reference value.

Of course, now when building a database, people usually use utf8mb4, so why not apply utf8? it's actually a pit.

Utf8 in mysql supports only three bytes per character, while the real UTF-8 is a maximum of four bytes per character, which counts as a bug of Mysql. In mysql, the character set that really supports UTF-8 is utf8mb4, which takes up four bytes.

The historical data goes like this:

In 2003, MySQL supported UTF-8 from version 4.1, but this is an old version of the standard (RFC 2279), and the new version of the UTF-8 standard (RFC 3629) appeared later.

RFC 2279 supports up to 6 bytes per character. But in September 2002, the MySQL source code was adjusted: "UTF8 now supports a sequence of up to 3 bytes." As for the reasons for the adjustment, there is no way to prove it at present.

It can be guessed that the original designer wanted to take up less space and achieve faster query speed. Six bytes is a little too much, and three bytes is enough. However, this also results in insufficient storage space and is not compatible with the RFC 3629 standard.

So utf8 can be said to be an original character set of mysql, which does not accord with the literal cognition. When people discovered his problem, they expected MySQL to fix it. However, for a variety of reasons, mysql did not fix the problem with utf8, but rereleased "utf8mb4" in 2010 to support real UTF-8.

So, say the important things three times.

In mysql, utf8 is not the character set that really supports UTF-8, but utf8mb4 is.

In mysql, utf8 is not the character set that really supports UTF-8, but utf8mb4 is.

In mysql, utf8 is not the character set that really supports UTF-8, but utf8mb4 is.

The above about why the construction of Mysql database is not applicable to utf8 details, is it helpful for everyone? If you want to know more about it, you can continue to follow our industry information section.

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