With MySQL server 5.7.27 connecting with Client 8.0.19. Getting Data too long for column when using special characters

QLands :

I have a MySQL table defined as follows in a 5.7 server:

+------------------------+-------------+------+-----+---------+-------+
| Field                  | Type        | Null | Key | Default | Extra |
+------------------------+-------------+------+-----+---------+-------+
| household_location_cod | int(1)      | NO   | PRI | NULL    |       |
| household_location_des | varchar(8)  | YES  |     | NULL    |       |
| rowuuid                | varchar(80) | YES  | UNI | NULL    |       |
+------------------------+-------------+------+-----+---------+-------+

The following insert works:

INSERT INTO lkphousehold_location (household_location_cod,household_location_des)  VALUES ('2',"Matiguas");

The following with (á) character don't:

INSERT INTO lkphousehold_location (household_location_cod,household_location_des)  VALUES ('3',"Matiguás");

This error did not happen when I connected with my 5.7.x client. Any idea why?

I see some answers about setting the sql_mode but the server has't changed, just the client from 5.7 to 8.0. Is this a client configuration?

ikyuchukov :

You are most likely using a different collation and character set, check the output of the following with your older client and your newer one:

mysql> SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | latin1 |
| character_set_connection | latin1 |
...
| character_set_results    | latin1 |
...
+--------------------------+--------+
mysql> SHOW SESSION VARIABLES LIKE 'collation_connection';
+----------------------+-------------------+
| Variable_name        | Value             |
+----------------------+-------------------+
| collation_connection | latin1_swedish_ci |
+----------------------+-------------------+

You can check https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html for additional information.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=31844&siteId=1