gpt4 book ai didi

MySQL 数据库 - 将字符集和排序规则转换为 utf8mb4 和 utf8mb4_unicode_ci?

转载 作者:行者123 更新时间:2023-11-29 07:37:34 24 4
gpt4 key购买 nike

我已按照建议使用 collowing 命令将我的 mysql 数据库的字符集和排序规则从 latin1 转换为 utf8mb4 here

ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

为了检查转换是否正确完成,我运行了以下命令。

  SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' 
OR Variable_name LIKE 'collation%'

输出是

enter image description here

虽然 character_set_client、character_set_connection、character_set_database、character_set_results 现在是 utf8mb4,character_set_filesystem 是二进制的,character_set_server 仍然是拉丁文。这些到底是什么以及为什么它仍然不在 utf8mb4 中?

同理,collat​​ion_connection和collat​​ion_database在utf8mb4_unicode_ci中,但是collat​​ion_server还是在latin1_swedish_ci中

最佳答案

https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_character_set_filesystem

This variable is used to interpret string literals that refer to file names, such as in the LOAD DATA INFILE and SELECT ... INTO OUTFILE statements and the LOAD_FILE() function. Such file names are converted from character_set_client to character_set_filesystem before the file opening attempt occurs. The default value is binary, which means that no conversion occurs.

您可能不需要更改此值。

https://dev.mysql.com/doc/refman/5.7/en/charset-server.html

The server character set and collation are used as default values if the database character set and collation are not specified in CREATE DATABASE statements. They have no other purpose.

您可以在 /etc/my.cnf 中更改此值,但这是多余的,因为如果您已经为每个数据库指定了字符集。

关于MySQL 数据库 - 将字符集和排序规则转换为 utf8mb4 和 utf8mb4_unicode_ci?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47997199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com