mysql encoding - garbled

*. A problem encountered in the development is that mysql uses gbk encoding, but the java project is utf8 encoding. After collecting a lot of information on the Internet, it finally lost to the so-called "common sense".

Information 1: http://blog.csdn.net/huyiyang2010/article/details/6202656/
In fact, what I said above is correct, the only difference is that my jdbc data comes from the configuration file, and characters that should not appear in the configuration file appear, such as:
useUnicode\=true&characterEncoding\=utf8
The correct one should be: useUnicode\=true&characterEncoding\=utf8
Hey, I'm so tired~

 

 

*, View database, table field encoding

库:show variables like 'character%';
字段:show full columns from tablename;

 

*. During development, it is often encountered that the Chinese parameter query in the tool is normal, but the database query in the project fails. At this time, no exception is thrown and there is no data result. At this time, you should think:

, Confirm the server-side encoding of the database
, Confirm that the call is the encoding method of the client
After performing these two operations, problems can generally be found, haha, such as inconsistent coding
At this point, modify the my.ini file under mysql/ (if not, please do it manually)
Add to:
character-set-server = utf8
character_set_client = utf8

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326176457&siteId=291194637