After the database is reinstalled, Chinese characters are garbled in the project.

Source: Internet
Author: User
The root cause of the garbled problem is that the encoding is not uniform. Since the project had no Chinese garbled characters before the database was reloaded, the problem must have occurred in the database encoding. After running mysql, enter the following command showvariableslikecharacter %; the author's query result is as follows: among them, character_set_client client Encoding

The root cause of the garbled problem is that the encoding is not uniform. Since the project had no Chinese garbled characters before the database was reloaded, the problem must have occurred in the database encoding. After running mysql, enter the following command show variables like 'character % '. The query result is as follows:

The root cause of the garbled problem is that the encoding is not uniform. Since the project had no Chinese garbled characters before the database was reloaded, the problem must have occurred in the database encoding.

After running mysql, enter the following command

Show variables like 'character % ';

The author's query results are as follows:


The character_set_client client encoding method;
Character_set_connection indicates the encoding used to establish a connection;
Character_set_database database encoding;
Character_set_results result set encoding;
Character_set_server database server code;

As long as the above four encoding methods are the same, there will be no garbled problem. It can be seen that the author's database is indeed prone to Encoding Problems .. The solution is also simple. You can add this to the database connection configuration file of each project.

Jdbc: mysql: // localhost: 3306/databasename? UseUnicode = true & characterEncoding = UTF-8
Or
Jdbc: mysql: // localhost: 3306/databasename? UseUnicode = true & characterEncoding = UTF-8
You can select one of them based on different XML parsing tools.


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.