[英]Adding collate to mysql database
I bumped into this error,when execting sql我在执行 sql 时遇到了这个错误
ERROR 1253 (42000) at line 25: COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'utf8mb4'
So I try to add utf8_general_ci
as the collate.所以我尝试添加
utf8_general_ci
作为整理。
alter database mydatabase character set utf8mb4_general_ci collate utf8_general_ci;
I have error like this How can I add the collate to existing database.我有这样的错误如何将整理添加到现有数据库中。
Or My idea is wrong?或者我的想法是错误的?
ERROR 1115 (42000): Unknown character set: 'utf8mb4_general_ci'
Thank you very much.非常感谢你。
I try this我试试这个
mysql> select *
-> from information_schema.collations
-> where CHARACTER_SET_NAME = 'utf8mb4'
-> and COLLATION_NAME like '%general%';
+--------------------+--------------------+----+------------+-------------+---------+---------------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN | PAD_ATTRIBUTE |
+--------------------+--------------------+----+------------+-------------+---------+---------------+
| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 | PAD SPACE |
+--------------------+--------------------+----+------------+-------------+---------+---------------+
1 row in set (0.00 sec)
then I try this sql, it works然后我试试这个 sql,它有效
alter database mydatabase character set utf8mb4 collate utf8mb4_general_ci;改变数据库 mydatabase 字符集 utf8mb4 整理 utf8mb4_general_ci;
but, first problem ( I am trying to introduce dump file)但是,第一个问题(我正在尝试引入转储文件)
ERROR 1253 (42000) at line 25: COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'utf8mb4' is not solved.
try to do this:尝试这样做:
ALTER DATABASE `DBname` COLLATE 'utf8mb4_unicode_ci';
Because you CHARACTER_SET_NAME is utf8mb4
you have the option to choose from these general collations:因为您的 CHARACTER_SET_NAME 是
utf8mb4
,所以您可以选择从这些通用排序规则中进行选择:
select *
from information_schema.collations
where CHARACTER_SET_NAME = 'utf8mb4'
and COLLATION_NAME like '%general%';
A CHARACTER SET
describes the encoding of characters. CHARACTER SET
描述了字符的编码。 It has a name like utf8mb4
, utf8
, latin1
, ascii
.它的名称类似于
utf8mb4
、 utf8
、 latin1
、 ascii
。
A COLLATION
says how to compare or sort strings. COLLATION
说明如何比较或排序字符串。 It has a name that starts with the CHARACTER SET
, then has something else added on.它的名称以
CHARACTER SET
开头,然后添加了其他内容。 Most collations end in _ci
(Case Insensitive) or _bin
(Binary -- blindly compare the bits).大多数归类以
_ci
(不区分大小写)或_bin
(二进制——盲目地比较位)结尾。
utf8mb4_general_ci
is a very old collation; utf8mb4_general_ci
是一个非常古老的排序规则; I recommend using a newer one, such as utf8mb4_unicode_520_ci
(available in most versions) or utf8mb4_0900_ai_ci
(in MySQL 8.0).我建议使用较新的,例如
utf8mb4_unicode_520_ci
(在大多数版本中可用)或utf8mb4_0900_ai_ci
(在 MySQL 8.0 中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.