Recently, with the idea to develop a Web APP project, build background on your PC and test is completed, ready to the background project as a whole from personal PC migration to the server, in various environment is configured and patches of all cases, the overall project running normally, but in writing data to MySQL, found all become the Chinese characters? I have a headache. Today I found time to summarize some solutions, so without further ado, let’s get to the point.

Method 1: First you should check whether your idea is inconsistent with the project code, resulting in page coding problems.

Method 2: Check whether the encoding used by the MySQL database is inconsistent, resulting in garbled characters.

 

Method 3: Check Hibernate and Spring transaction processing, connection to the database problems.

Method 4: Check the Mysql parameter and find that character_set_server is latin1, which is inconsistent with the project coding.

Modify your MySQL my.ini file.

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8
basedir=C:\Program Files\MySQL\MySQL Server 5.7
datadir=C:\Program Files\MySQL\MySQL Server 5.7\data
port = 3306
Copy the code