MySQL character set problem solution (including changing configuring files, command line modifications, and JDBC issues)

xiaoxiao2021-03-06  19

Mysql 4.1 Character Set Support has two aspects: Character Set, and Collation. For the support of the character set to four levels: Server, Database (Database), Dataset (Table), and Connection.

View the character set and sorting mode of the system can pass the following two commands:

Mysql> show variables like 'character_set_%';

-------------------------------------------------------------------------------------------------------------------------------------------------- ------

| Variable_name | Value |

-------------------------------------------------------------------------------------------------------------------------------------------------- ------

| character_set_client | Latin1 |

| Character_Set_Connection | Latin1 |

| Character_Set_Database | Latin1 |

| Character_set_Results | Latin1 |

| character_set_server | latin1 |

| Character_SET_SYSTEM | UTF8 |

| character_sets_dir | / usr / share / mysql / charsets / |

-------------------------------------------------------------------------------------------------------------------------------------------------- ------

7 rows in set (0.00 sec)

Mysql> Show variables like 'collation_%'; ---------------------------------------------------------------------------------------------------------------------------- --- | Variable_name | Value | ----------------------------------------- - | Collation_connection | Latin1_Swedish_ci || Collation_Database | Latin1_Swedish_ci || Collation_Server | Latin1_Swedish_ci | -------------------- ---------------- ---------------- -------------- ---------------- ------ ----------- 3 ROWS IN SET (0.00 sec) The value listed above is the default value of the system. Even if the default character set of the table is set to UTF8 and send a query through the UTF-8 encoding, you will find that the database is still garbled. The problem is on this Connection connection layer. The solution is to perform the following sentence before sending a query:

Set names 'UTF8';

转载请注明原文地址:https://www.9cbs.com/read-53563.html

New Post(0)