MySQL中文乱码解决方案

问题描述:插入MySQL中文乱码。解决方案如下:

1,打开MySQL安装目录的my.ini,如图

在[mysql],[mysqld]后面添加default-character-set=utf8。把character-set-server=latin1改为character-set-server=utf8。重启MySQL服务。

show VARIABLES like '%char%'

这样编码就都改为了utf8。再次插入中文就正常了。

还有另一种方案:

建立数据库和表的时候,都显示指示utf8,在连接数据库的时候显示指示编码,jdbc:mysql://localhost:3306/test_customer?useUnicode=true&characterEncoding=utf8.

 

posted @ 2018-01-25 11:11  阿罗luo  阅读(190)  评论(0)    收藏  举报