java Mysql Chinese character garbled solution: 1. Check the front-end page encoding and set the encoding format to "utf-8"; 2. Check the IDEA development tool encoding and set it to "utf-8"; 3. Open my.ini configuration file and set "character-set-server=utf-8".
The operating environment of this tutorial: Windows 10 system, MySQL version 5.7, Dell G3 computer.
java mysql What should I do if the Chinese characters are garbled?
java adds Chinese data to the Mysql database, and garbled characters are displayed in the database
When using springboot to do a project, due to the reinstallation of the local Mysql database (version 5.7), when inserting and updating data into the database at the front desk, the database always displays when Chinese is involved. Exception (question mark displayed in Chinese).
Analysis reason: The data display is all ? No., it should be a data encoding problem. Check whether the encoding method is unified in the front-end, back-end, and database (set to utf-8 uniformly).
1. Check the front-end page encoding: Front-end encoding
<meta> …
The encoding format is utf-8, there is no problem. Next step...
2. Check whether the IDEA development tool encoding is utf-8:
Find the file encoding in the settings (search for Project Econding It also works), changed it to utf-8., updated and ran the inserted data, but it still didn't work. Next step...
3. Check if there is any problem with the database url:
url: jdbc:mysql://localhost:3306/root?useUnicode=true&characterEnconding=UTF-8
Add useUnicode=true&characterEnconding=UTF-8, double-click to run, still the same? No., next step (edge of collapse)...
*** Note that the format of my configuration file here is yml. If it is xml, & needs to be escaped.
4. Check whether the database my.ini configuration is correct:
Due to the reinstallation of Mysql, the version is a little different from the previous one. Is there a problem with my own database?
Open the Mysql installation directory: look for the my.ini configuration file
Is it a folder, or is it empty? ? ?
Backhand Baidu, some experts said it is in other folders (under ProgramData on the C drive). I looked for it and it’s really there!
Open in text mode:
Found that this has no initial value, add the initial value.
Save and close. Restart the MySQL service (note that the MySQL service must be restarted after modifying the configuration file to be useful)
Restart the project and insert Chinese data,
The display is normal, ok done! .
Recommended study: "MySQL Video Tutorial"
The above is the detailed content of What to do if Chinese characters are garbled in java mysql. For more information, please follow other related articles on the PHP Chinese website!