Saving Emojis in MySQL utf8mb4 Database: Troubleshooting Invalid Character Errors
When attempting to store names containing emojis in a MySQL database, errors like "Invalid utf8 character string" may arise despite proper configuration.一个潜在的问题在于不一致的字符集和整理设置。
要验证配置,执行以下查询:在其中variable_name喜欢'cartinal \ _set \ _set \ _%'%'%''或variable_name的一个collation%'collation%'; [collation%'; [&us&&us&&ustriake ford fortabe] colled; [&ustration%;
;SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
- - - - - - - - - - - - - - - - - - - - - - - | variable_name |值| ------------------------------------------------------------------- | targin_set_client | UTF8MB4 | | targin_set_connection | UTF8MB4 | | targin_set_database | UTF8MB4 | | targin_set_filesystem |二进制| | targin_set_results | UTF8MB4 | | targin_set_server | UTF8MB4 | | targin_set_system | UTF8 | | Collation_Connection | UTF8MB4_UNICODE_CI | | Collation_Database | UTF8MB4_UNICODE_CI | | Collation_Server | UTF8MB4_UNICODE_CI | -------------------------- --------------------
-------------------------- -------------------- | Variable_name | Value | -------------------------- -------------------- | character_set_client | utf8mb4 | | character_set_connection | utf8mb4 | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | utf8mb4 | | character_set_server | utf8mb4 | | character_set_system | utf8 | | collation_connection | utf8mb4_unicode_ci | | collation_database | utf8mb4_unicode_ci | | collation_server | utf8mb4_unicode_ci | -------------------------- --------------------此外,检查my.cnf配置文件是否包含任何不一致之处。搜索指定字符集和校正的设置,并确保它们与数据库配置一致。例如,验证这些行是否存在:
artight-client-handshake = false 字符 - 设定服务器= UTF8MB4 comlation-server = utf8mb4_unicode_ci
如果这些设置不存在或不正确,请根据需要进行修改,然后重新启动mysql服务。这将确保所有三个字符集变量都正确设置。
通过遵循以下步骤,您可以在使用mySQL数据库中保存emojis时解决无效的UTF-8字符错误,以解决UTF8MB4 configuration。免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3