群集中的AWS Aurora RDS(mysql)无法插入表情符号 [英] aws aurora rds (mysql) in a cluster cannot insert emoji
问题描述
我在群集中使用aurora rds(mysql),但是无法插入表情符号.我尝试插入的列具有以下排序规则:
I am using an aurora rds (mysql) in a cluster and cannot insert emoji's. The column which I am trying to insert into has the collation:
utf8mb4-utf8mb4_unicode_ci
utf8mb4 - utf8mb4_unicode_ci
我尝试使用客户端插入,也尝试从mysql工作台中编写查询,但是在两种情况下我都只看到????在现场.
I have tried inserting using client and also from mysql workbench writing the query but in both cases I just see ???? in the field.
我已经更新了表的默认字符集: utf8mb4 和默认排序规则: utf8mb4_unicode_ci
I have updated the table default character set: utf8mb4 and default collation: utf8mb4_unicode_ci
但仍然得到???而不是表情符号
But still getting ??? instead of emoji
我尝试编辑集群的参数组,并将所有字符集值设置为utf8mb4,并将所有排序规则值设置为utf8mb4_unicode_ci,但仍然无法正常工作.
I've tried to edit the parameter group of the cluster and set all character set values to utf8mb4 and all collation values to utf8mb4_unicode_ci but still not working.
推荐答案
您的集群参数组应设置以下选项:
Your cluster parameter group should have the following options set:
- character_set_client:utf8mb4
- 字符集连接:utf8mb4
- 字符集数据库:utf8mb4
- 字符集服务器:utf8mb4
- collation_connection:utf8mb4_unicode_ci
- collation_server:utf8mb4_unicode_ci
更新后可能需要重新启动实例.当您连接到群集时,您想要为连接设置正确的排序规则,如下所示:
Rebooting your instances after updating this might be required. When you connect to the cluster you want to set the correct collation for your connection, like this:
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
如果在此之后运行SHOW VARIABLES LIKE "%collation%"
,则应该看到三个变量都具有正确的排序规则(utf8mb4_unicode_ci).
If you run SHOW VARIABLES LIKE "%collation%"
after this you should see three variables that all have the correct collation (utf8mb4_unicode_ci).
您还需要将表和列转换为正确的字符集和排序规则,这已在DBA Stack Exchange上得到了解决:
You also need to convert your tables and columns to the correct charset and collation, this has been answered before on the DBA Stack Exchange: How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
这篇关于群集中的AWS Aurora RDS(mysql)无法插入表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!