Mysql4.1.7 character set problem

xiaoxiao2021-03-05  19

Copyright Notice: If there is a reprint request, please indicate: http://blog.9cbs.net/yzhz

Environment: 1. MySQL Database Version: mysql4.1.72, mysql driver: mysql-connector-java-3.1.73, environment: Windows Platform 4, specifying character-set for GBK when installing MySQL database

I have encountered the problem: Using JDBC access database, JDBC's URL: JDBC: MySQL: // localhost: 3306 / Club, read and write database display Chinese is normal. But in the console in MySQL, Chinese is displayed in Chinese? The reason is: MySQL 4.1 or later adds several variables, character_set_client by default, character_set_connection, character_set_results value is latin1 character_set_client | latin1character_set_connection | latin1character_set_database | gbkcharacter_set_results | latin1character_set_server | gbkcharacter_set_system | utf8 so in the console to see the Chinese record for solving? The method is: Set the default-character-set mysql -uuser -ppassword -default-character-set = GBK TEST when starting console

Character_set_client | GBKCHARACTER_SET_CONNECTION | GBKCHARACTER_SET_DATABAS | GBKCHARACTER_SET_RESULTS | GBKCHARACTER_SET_SERVER | GBKCHARACTER_SET_SYSTEM | UTF8

Summary: 1. MySQL4.1 or above, mysql jdbc driver3.0.16 or later, JDBC's URL does not have to bring UseUnicode = true & eNCodingCharacter = GBK, the JDBC driver automatically detects the Mysql server's variable (character_set_server) as specified when the connection is connected. Encode, then convert Java Unicode String to the specified character set to the MySQL Server.2, MySQL4.1.7 version database, Character-set is GBK, if the console is garbled, bring the parameters when starting console --default -Character-set = GBK

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

New Post(0)