M
M
Max Payne2018-10-23 01:38:59
MySQL
Max Payne, 2018-10-23 01:38:59

Why is there an Incorrect string value error in utf8mb4 encoding?

Why does the error occur

Incorrect string value: '\\xD0\\xBF\\xD1\\x80\\xD0\\xB8...' for column 'phrase' at row 1

In spite of
+--------------------------+----------------------------+
| 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                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

Given that all databases have been converted to utf8mb4 using
ALTER DATABASE schema_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

And all the tables in them are also translated into utf8mb4 using
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2018-10-23
@ThunderCat

SET character_set_connection = utf8mb4;
SET character_set_client = utf8mb4;
SET character_set_results =  utf8mb4;

It seems that it is necessary to specify this when establishing a connection, I'm not sure that they do not get lost when a client connection is made.
PS: I'm not sure, but it seems like COLLATE utf8mb4_general_ci;
see more here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question