A wonderful record of mysql Chinese garbled

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/dataiyangu/article/details/100586462


background

The idea is not in the local Chinese distortion, but the distortion on the linux server (insertion operation).

Investigation

Check coding of database jdbc

Here Insert Picture Description
no problem

View encoding linux server

locale
Here Insert Picture Description
without problems
must be noted that: If the default language is en_US.UTF-8, are unable to display and input Chinese characters and in the Linux graphical interface. If the default language is Chinese, such as zh_CN.GB18030 or zh_CN.gb2312, not character display and input interface, graphical interface.
So here's zh_CN.UTR-8 is correct
https://www.cnblogs.com/saneri/p/5779119.html

View mysql server encoding

/etc/mysql/my.cnf
then open the my.cnf, add:
[Client]
default = utf8-Character-the SET
in [mysqld] this inside, add
character-set-server = utf8
save, and restart the mysql service on the line a.
Restart command service mysql restart
or more from: https: //blog.csdn.net/anod/article/details/77876974

By show variables like 'character%'; see characters,
the SET = the character_set_database UTF8;
after a reboot deleted database table, a new database table; SET character_set_server = utf8
above from: https: //blog.csdn.net/zl834205311/article/ details / 81703560

By viewing or no problem

Never thought

Think about it, there is no local problem, move to linux is a problem, the problem can not be mysql server, and can only be coded linux server problem, but after investigation is no problem, then finish the war by opening ~ ~ ~ package, view class file
Here Insert Picture Description
transfixed, packing it wrong, warehousing which can not mess it me? Wise and farsighted

Final settlement

maven plugin utf-8 was added to

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.2</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

Guess you like

Origin blog.csdn.net/dataiyangu/article/details/100586462