Hibernate inserts mysql Chinese garbled characters to solve the problem of mysql version 5.5 ??????? Some time ago, I reinstalled the system and learned about hibernate. When I first started using the oracle database, there was no Chinese Garbled text. However, after converting to mysql, I inserted Chinese characters and then Garbled text, I thought it was the cause of incorrect encoding format when installing mysql, and then uninstalled it again.
Hibernate inserts mysql Chinese garbled characters to fix mysql version 5.5? ?????? Some time ago, I reinstalled the system and learned about hibernate. When I first started using the oracle database, there was no Chinese Garbled text. However, after converting to mysql, I inserted Chinese characters and then Garbled text, I thought it was the cause of incorrect encoding format when installing mysql, and then uninstalled it again.
Solve Chinese garbled characters inserted into mysql by hibernate
My mysql version 5.5
?
?????? Some time ago, I reinstalled the system and learned about hibernate. When I first started using the oracle database, there was no Chinese Garbled text. However, after converting to mysql, I inserted Chinese characters and then Garbled text, I thought it was the reason why I chose the wrong encoding format when installing mysql, and then uninstalled and re-installed it. As a result, I installed it multiple times, but the same garbled code. I tried it on the Internet and then tested it myself, two solutions:
1. Change the connection string
Jdbc: mysql: // localhost/hibernate? UseUnicode = true & characterEncoding = GBK
This method was used at the beginning and can solve the problem of inserting Chinese garbled characters. However, since I have been using navicat to connect to the database, it is more convenient. There is no garbled Chinese characters and I have never used the console, today, when I used the console to connect to the database, Chinese characters were garbled. Solution 2
2. Open the mysql Chinese installation directory and open my. ini changes the default-character-set value to GBK, and the character-set-server value to utf8. After the change, no garbled code occurs when hibernate is inserted into the database, and no garbled code is found on the console, the connection string can finally be changed back to jdbc: mysql: // localhost/hibernate, which does not have to be so long. For other MySQL versions, it is not clear but should be similar, search character to find the encoding format.
Last friendly reminder: Remember to back up the source file before changing my. ini to prevent exceptions.
(This article is only intended for the same people as me. Please ignore it)