Mysql Chinese garbled problem solving

The first is to modify the Mysql database encoding and change it to utf-8, the default is latin1 (recommended);

QQ drama 20160202132103.png As shown in the figure, find the mysql installation and click on the mysql instance configuration


1454390537171022264.jpg

 

 Keep clicking next to know the following interface:

QQ drama 20160202132310.png

Remember, the previous circle is a little bit important. . Drop-down box to select utf8


Continue next until:

QQ drama 20160202132431.png

Write your original password to continue, then continue to Next:

QQ drama 20160202132517.png

Click to execute

QQ drama 20160202132618.png

This is OK;


This is done. Remember to delete the original imported project database and re-import it;


Second, modify the jdbc request url to specify the encoding (not recommended)

Add ?useUnicode=true&characterEncoding=UTF-8 after the jdbc url to specify the encoding;

If it is to be escaped in the xml configuration file, ?useUnicode=true&characterEncoding=UTF-8;

For example, in the spring configuration file:

1
2
3
4
5
6
7
<!-- 配置数据源 -->
     < bean  id = "dataSource"
         class = "com.alibaba.druid.pool.DruidDataSource" >
         < property  name = "url"  value = "jdbc:mysql://localhost:3306/db_blog?useUnicode=true&amp;characterEncoding=UTF-8" />
         < property  name = "username"  value = "root" />
         < property  name = "password"  value = "123456" />
     </ bean >


The first is recommended;


Guess you like

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