MySQL中文乱码修改
一、从服务端进行修改
show variables like "%char%";
然后可能显示如下信息,注意红色部分,不同的用户可能实际情况不同,但是需要保证除了 filesystem为binary外,其他都为utf8:
+--------------------------+---------------+ | Variable_name | Value | +--------------------------+---------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | utf8 | | character_set_system | utf8 | +--------------------------+-------------+
通过如下SQL语句进行修改,全部设置为utf8即可:
#设置数据库编码信息 SET character_set_client='utf8'; SET character_set_connection='utf8'; SET character_set_database ='utf8'; SET character_set_results='utf8'; SET character_set_server='utf8';
二、SQL连接字符串加上?useUnicode=true&characterEncoding=utf-8
jdbc.url = jdbc:mysql://localhost:3306/bsframe?useUnicode=true&characterEncoding=utf-8
一般按照上述步骤后,就不会出现乱码了!
Doing is better than nothing