In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you springboot and database return data Chinese garbled how to do, I believe that most people do not understand, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
Problem description: when using springboot to operate the database, the returned Chinese data is always garbled
At first, I thought it was the problem of springboot. I have been searching the Internet for springboot and the returned data is garbled.
As a result, my problem is not right at all. I can't solve it at all.
Later, it was found that it should be the problem of mysql database, so I searched the Internet and finally decided that it was the problem of character set.
Resolution process:
First use the SQL statement to view the character set of the database
Show variables like 'character%'
It is found that many places are not utf8. If you want to modify the mysql configuration file, you need to modify the configuration file. Many changes on the Internet are modified using commands, but this method is only local. After the mysql service is restarted, these changes are invalid, so you need to modify the configuration file.
Because my operating system is windows, my mysql configuration file is my.ini, and the specific path is under C:\ ProgramData\ MySQL\ MySQL Server 8.0
Maybe the ProgramData folder of some computers is hidden, just check the hidden items in it.
It is recommended that you first run a notepad with an administrator, and then open the my.ini file in it.
Add the following code block under [client] [mysql] [mysqld] respectively, and be careful not to add # in front of it.
[client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4 [mysqld] character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = utf8mb4_unicode_ciinit_connect = 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci'init_connect =' SET collation_connection = utf8mb4_unicode_ci' after successful modification, use the administrator to run cmd and run the following two commands to restart the mysql service (mysql80 is the name of the service, which may also be called mysql)
Net stop mysql80
Net start mysql80
After restarting, use the mysql command to query the character set again, and find that multiple character sets have become utf8mb4.
At this time, it means that the modification is successful, and then because the modified character set is not valid for the existing database, you have to delete the database you operate, rebuild it, and finally succeed!
The above is all the contents of the article "how to garble the data returned by springboot and database". Thank you for your reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.