I change column character set to utf8mb4 to support emojis, but when character_set_connection/character_set_client is set to utf8, inserting data returns "Incorrect string value xxx for column xxx at row 1". I can not successfully insert data until I set character_set_connection/character_set_client to utf8mb4 too. I think the parameters above are used to communicate with mysql clients, when statements are successfully received by server, they are already transfered to utf8(otherwise errors should occur here), when inserting data with utf8 encoding to column of utf8mb4 encoding, there should not be any errors. So, why the error occurs here?
Asked
Active
Viewed 56 times
0
-
1*character_set_connection* specified the charset/colation which will be applied to the string literals values transferred via this connection. If you want the independence from this setting then you must use explicit CONVERT() function in your query. – Akina Oct 25 '21 at 10:44
-
Thank you very much, but I still don't understand why the error doesn't occur at the time when server receive the statement, but occur when server try to insert data? – ccc Oct 27 '21 at 07:37
-
The literal is legal itself for your charset settings, so the problem is not detected during query text receiving and execution plan building. But the value is not legal for the charset specified for a column - so it is detected during insertion attempt. – Akina Oct 27 '21 at 07:40