Error 1366 (22007): Incorrect string value:

failed: update: Error 1366 (22007): Incorrect string value: ‘\xF0\x9F\x9A\x80\xE5\x82…’ for column Dev_gitea_old.repository.description at row 1

镜像的时候报这种错误怎么解决?
数据库以及表的编码都是utf8mb4 的

What is result of following query? I think encoding of column might not be utf8mb4 if database and table encoding are set correctly.

USE Dev_gitea_old;
SHOW FULL COLUMNS FROM repository;

If above shows description as proper collation, it could be issue with connection encoding. This query shows what connection settings are:

SELECT * FROM performance_schema.session_variables
WHERE VARIABLE_NAME IN (
  'character_set_client', 'character_set_connection',
  'character_set_results', 'collation_connection'
) ORDER BY VARIABLE_NAME;

https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html

块引用
What is result of following query? I think encoding of column might not be utf8mb4 if database and table encoding are set correctly.

列也是utf8mb4的

块引用
If above shows description as proper collation, it could be issue with connection encoding. This query shows what connection settings are:

客户端连接的也是utf8mb4的

可以镜像下这个地址 GitHub - aoaostar/toolbox: 🚀傲星工具箱,一个在线工具箱
此地址从网上找的有侵权请联系删除

Can you share database software name and version? Can you also share configuration file for database software (in MySQL it would be my.cnf)?

10.11.3-MariaDB, for Linux (x86_64)

Can you check character_set_connection, collation_connection in my.cnf? These options default to utf8mb3 and might be causing problem.

If not issue, you can check other similar name variables. Here is documentation.

微信截图_20230602155824

这是my.cnf

Apologies for late reply. I recently saw issue on GitHub that reminded me of this post.

Can you verify that CHARSET under [database] is set to utf8mb4? See Config Cheat Sheet, there is a recent bug where it is accidentally set to utf8 which prevents users adding emojis to text which is what is causing Incorrect string value error.

1 Like