php - 日文/英文输入的mysql数据库: utf8_unicode_ci or utf8mb4_unicode_ci?

标签 php mysql

我目前正在开发一个包含日语和英语字符串的 mysql 数据库。

当前排序规则:utf8_general_ci。

我必须使用 LIKE %'japaneseWordHere'% 查询字符串中的日语单词。目前它与 utf8_general_ci 几乎可以正常工作,但有时它会跳过一条记录,因为我假设前一个/后续字符未正确存储在 utf8_general_ci 中。

我发现 utf8_general_ci 有点旧并且有 bug,并了解到:

  1. utf8_unicode_ci
  2. utf8mb4_unicode_ci

我正在阅读一些内容,但无法具体找到一个好的答案。

如果有人使用日本 myslq 数据库或知道什么是最好的,任何回复都将受到欢迎。

我应该从 utf8_general_ci 更改为 utf8_unicode_ciutf8mb4_unicode_ci 吗?

最佳答案

<强>1。 utf8_general_ci 和 utf8_unicode_ci 之间

UTF-8 is an encoding for the Unicode character set, which supports pretty much every language in the world.

The only difference comes with sorting your results, different letters might come in a different order in other languages. Also, comparing a to ä might behave differently in another collation.

<强>2。 utf8mb4_unicode_ci 和 utf8_unicode_ci 之间

For a BMP character, utf8 and utf8mb4 have identical storage characteristics: same code values, same encoding, same length

For a supplementary character, utf8 cannot store the character at all, while utf8mb4 requires four bytes to store it. Since utf8 cannot store the character at all, you do not have any supplementary characters in utf8 columns and you need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.

关于php - 日文/英文输入的mysql数据库: utf8_unicode_ci or utf8mb4_unicode_ci?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28017127/

相关文章:

php - Analytics API返回不正确的日期和正确的值

php - 如何向每个页面添加一个 MySQL 命令

mysql - 将值插入到基于另一个表的表中

mysql - 使用 Mysql 数据库在 Node.js 中手动创建用户时出错“TypeError : User. findById is not a function

php - 目录中记录的文件名与数据库不同

php - Elasticsearch 不确定我是否需要使用 bool 查询

php - 在extjs中如何获取上传文件的内容

php - 有什么办法可以告诉用户一个表中有多少行?

php - 如何使用 AJAX 将数组值传递给 PHP?

php - 无法根据 SQL 输出创建单独的论坛类别