简体   繁体   English

数据库从 latin1 到 utf8mb4 的转换,索引呢?

[英]Database conversion from latin1 to utf8mb4, what about indexes?

I noticed that my MODX database still uses latin1 character set in the database and in its tables.我注意到我的 MODX 数据库在数据库及其表中仍然使用 latin1 字符集。 I would like to convert them to utf8mb4 and update collations accordingly.我想将它们转换为 utf8mb4 并相应地更新排序规则。

Not totally sure how I should do this.不完全确定我应该如何做到这一点。 Is this correct?这样对吗?

  • I alter every table to use utf8mb4 and utf8_unicode_ci?我更改每个表以使用 utf8mb4 和 utf8_unicode_ci?
  • I update the default character set and collation of the database.我更新了数据库的默认字符集和排序规则。

Are indexes updated automatically?索引会自动更新吗? Is there something else I should be aware of?还有什么我应该注意的吗?

A bonus question: what would be the most suitable latest utf8_unicode collation?一个额外的问题:最合适的最新 utf8_unicode 排序规则是什么? Western languages should work.西方语言应该有效。

Changing the default character sets of a table or a schema does not change the data in the column itself, it only changes the default to apply the next time you add a table or add a column to a table.更改表或架构的默认字符集不会更改列本身中的数据,只会更改下一次添加表或向表中添加列时应用的默认值。

To convert current data, alter one table at a time:要转换当前数据,请一次更改一张表:

ALTER TABLE <name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

The collation utf8mb4_0900_ai_ci is faster than earlier collations (at least according to the documentation ), and it's the most current and accurate.归类 utf8mb4_0900_ai_ci 比早期的归类更快(至少根据文档),并且它是最新和最准确的。 This collation requires MySQL 8.0.此排序规则需要 MySQL 8.0。

The most current collation in MySQL 5.7 is utf8_unicode_520_ci. MySQL 5.7 中最新的排序规则是 utf8_unicode_520_ci。

A table-conversion like this rebuilds the indexes, so there's nothing else you need to do.像这样的表转换会重建索引,因此您无需执行任何其他操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将MySQL数据库从latin1更新为utf8mb4:最大密钥长度为767字节 - Updating MySQL database from latin1 to utf8mb4: max key length is 767 bytes 从 Latin1 SQL 服务器迁移到 utf8mb4 MySQL 错误字符串错误问题 - Migrating from Latin1 SQL Server to utf8mb4 MySQL Incorrect String Error Problems MySQL服务器的编码与客户端的编码不同(latin1与utf8mb4)。 有多糟 - Mysql server's encoding differs from the client's (latin1 vs utf8mb4). How bad is it? 如何将 latin1 字符集客户端发送的字符转换为 utf8mb4 - how to convert latin1 charset client-sent character to utf8mb4 将完整数据库从utf8mb3(utf-8)转换为utf8mb4而没有停机时间的正确方法是什么? - What is the proper approach to convert complete database from utf8mb3 (utf-8) to utf8mb4 with no downtime? 从latin1 db到utf8数据库的导入数据库转储 - imported database dump from latin1 db to utf8 database MySQL 数据库 - 将字符集和排序规则转换为 utf8mb4 和 utf8mb4_unicode_ci? - MySQL database - conversion of characterset and collation to utf8mb4 and utf8mb4_unicode_ci? 在JDBC中将Wacky Latin1转换为UTF8 - Whacky latin1 to UTF8 conversion in JDBC 将庞大的数据库从Latin1转换为UTF8? - Convert huge database from Latin1 to UTF8? 什么是 utf8mb4 中没有在 MySQL 中的 utf8? - What is in utf8mb4 that is not in utf8 in MySQL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM