Home>Article>Database> What to do if Chinese characters are garbled in java mysql

What to do if Chinese characters are garbled in java mysql

藏色散人
藏色散人 Original
2023-02-14 10:42:56 2516browse

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".

What to do if Chinese characters are garbled in java mysql

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

Problem description

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).
What to do if Chinese characters are garbled in java mysql

What to do if Chinese characters are garbled in java mysql

Problem solving process:

  • 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

    The encoding format is utf-8, there is no problem. Next step...

    2. Check whether the IDEA development tool encoding is utf-8:
    What to do if Chinese characters are garbled in java mysql
    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
    What to do if Chinese characters are garbled in java mysql
    What to do if Chinese characters are garbled in java mysql
    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!
    What to do if Chinese characters are garbled in java mysql
    Open in text mode:
    What to do if Chinese characters are garbled in java mysql
    Found that this has no initial value, add the initial value.
    What to do if Chinese characters are garbled in java mysql
    Save and close. Restart the MySQL service (note that the MySQL service must be restarted after modifying the configuration file to be useful)
    What to do if Chinese characters are garbled in java mysql
    What to do if Chinese characters are garbled in java mysql
    Restart the project and insert Chinese data,

What to do if Chinese characters are garbled in java mysqlThe 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn