A sad history of processing MySQL database Chinese garbled characters (I almost cried all afternoon)

Source: Internet
Author: User

MySQL Default character encoding is Latin1, and Java corresponds to the ISO-8859-1. To correctly display our Chinese characters, you only need to change the character encoding method of MySQL from Latin1 to Chinese and change it to "GBK" or "gb2312 ", there are two ways to modify:
one is to reconfigure mysql. In its Configuration Wizard, one is to enable you to select character encoding. You can choose Custom options, then define it as "GBK" or "gb2312".
the other is to directly modify "My. INI file. Find the file in the MySQL installation directory and open it in Notepad. Find the following two sentences:
[My SQL]
default-character-set = Latin1
[My sqld]
......
......
default-character-set = Latin1
replace Latin1 with "GBK". Be sure to use lower-case letters. I heard that uppercase letters are not recognized.

After the MySQL database is modified, we only need to set the character set of the JSP page to GBK.
<% @ Page Language = "Java" contenttype = "text/html; charset = GBK"
Pageencoding = "GBK" %>
If a filter exists, you should change the encoding format in the filter to GBK.

No other modifications are required. The garbled problem in the database should be solved.

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.