解决方法:
1、修改mysql配置进入mysql命令行模式,show variables like 'character%';显示所有字符集名称其中除了character_set_filesystem=binary character_sets_dir= /usr/share/mysql/charsets/(依据个人配置路径而定)以外,其他都改成统一的编码,如utf8。A)找到my.cnf(默认在/etc/mysql/my.cnf)B)在[client]下加入default-character-set=utf8C)在[mysqld]下加入character_set_server=utf8D)保存退出,重启服务service mysql restartE)重启成功后,进入myslq命令行,show variables like 'character%';查看字符集名称是否统一,如下图:+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+注:服务器字符集 (character_set_server)库字符集 (character_set_database)数据库系统(character_system)character_set_server: 服务器安装时指定的默认字符集设定。character_set_database: 数据库服务器中某个库使用的字符集设定,如果建库时没有指明,将使用服务器安装时指定的字符集设置。character_system: 数据库系统使用的字符集设定。2、链接字符串加入参数jdbc:mysql://IP:3306/databasename?useUnicode=true&characterEncoding=utf8如果是放置在XML的配置文件中,修改为<![CDATA[jdbc:mysql://10.83.211.150:3306/etpsp?useUnicode=true&characterEncoding=utf8]]>因为里面有特殊字符至此乱码解决