MySQL 4.1.9 UTF-8 character set problem solved

xiaoxiao2021-03-06  46

In order to use a full-text search, I upgraded my MySQL to MySQL 4.1.9. According to the MySQL document, you must use the UTF8 character set. After the installation, when I came over, I used MySQL Client's search, and the whole is the garbled code of the people '????'. But the new INSERT in the new table is normally when SELECT comes out. This is what I thought I got, I am very happy to download a new version of MySQL JDBC Driver: JConnector-3.0.16, misfortune happened, and all garbled. I used the test table name of the TTT, and later I opened the TTT.myd file and found that the word stream of the Chinese characters did not be the correct UTF-8 encoded byte stream.

Finally, I used JDBC into the Chinese character, and it was correct with JDBC SELECT. But this is mysql-client select comes out of garbled. Check out the mysql client command line help

It is found that there is also a - DEFAULT-CHARACTER-SET option, running mysql --default-character-set = UTF8 or not, finally try mysql --default-character-set = GBK successfully. It seems that the Mysql Client's character set option is set to the operating system.

Finally, I will tell me what I may benefit to you when I look for the MySQL character set document.

1) MSYQL 4.1 When using JConnector 3.0.16 (this version used to be a traditional way), it specifies what the character set (UseunicE = true & characterencoding = GBK) regardless of the JDBC URL, it automatically uses the character set set by MySQL Server. Unless another parameter useoldutf8behavior = true & user = true & characterencoding = ISO8859-1 can be compatible with the previous database table.

2) You can use the ALTER DATABASE TEST CHARACTER SET UTF8 command to modify the character set (not verified) of the database, so different database character sets can be different. Some people say that every table can be different, but I have not tried it.

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

New Post(0)