On November 14, 2019, when I went to Party A’s site to deploy the project for their local server, I set up JDK, MySql and Tomcat environment and deployed the WAR package. After that, I directly visited localhost:8080/index and found there was no problem. However, when I just said there was no problem and was ready to start the demonstration, I found that Chinese garbled characters appeared after the Add method of the first step was executed.

Mysql > install mysql > set the character encoding to UTF8


Solution 1:

1. Query the database character encoding format: root MySqlPassword!

show variables like ‘character%’;

In normal cases, the upper part is not configured as the lower part




2. Modify the mysql configuration file

The default configuration file path is C:\ProgramData\MySQL\MySQL Server 5.7\my.ini

[mysql]

default-character-set=utf8

[mysqld]

character_set_server=utf8

[mysql] are client-side encoding Settings, [mysqld] are server-side Settings.

3. Copy the modified configuration file to the Mysql installation path C:\Program Files\ Mysql \ Mysql Server 5.7


Solution 2:

There is no need to modify the mysql configuration file, just append the character encoding Settings to the URL path where the project configures JDBC

url: jdbc:mysql://localhost/tendering? characterEncoding=utf8&useSSL=false&useUnicode=true& 0 =true&useLegacyDatetimeCode=false&serverTimezone=UTCCopy the code

The measured effective