UTF-8 easily solves the problem of MySQL Chinese Character Input and JSP page Chinese Character Display

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.