I encountered a Chinese character display problem when connecting to MySQL.
At first, the database was unable to input Chinese data.
When I create a table and insert data, an error occurs: date too long for column...
After searching by multiple parties, the solution is found to modify the my. ini configuration file under the MySQL installation directory.
Add this sentence after the [client] in the file:
Default-character-set = GBK
That is:
[Client]
Default-character-set = GBK
Port = 3306
Restart the MySQL server and enter data.
However, when you use the SELECT statement to query, all Chinese characters must be displayed as null or empty.
Besides, the data displayed on the JSP page is empty or garbled.
Finally, the solution is found, that is, the my. ini file is modified as follows:
Modify the MySQL database configuration file my. ini as follows:
[MySQL]
Default-character-set = GBK
# Important: this setting is the command line display and input of MySQL.
# Renewal #-------------------------------------------------------------------------------------------------------------
[Mysqld]
Default-character-set = utf8
# Important: This setting determines the character set of the MySQL work environment! The database inherits the character set by MySQL, while the table inherits the character set of the database, and the field inherits the character set of the table! So setting is very important here!
After changing these, as long as the JSP page encoding methods are set to UTF-8 can completely solve the problem ......
Note that the UTF-8 in MySQL should be written as utf8, otherwise errors will occur