mysql乱码问题总结:
(1)java中处理字符正常,在cmd client 或者Myeclipse控制台打印显示是乱码。 (2)数据库中设置的字段长度够长,但是插入中文字符的时候提示com.mysql.jdbc.MysqlDataTruncation:Data truncation:Data too long for column 这类问题都是字符编码的问题,解决方法无外乎server,client,database,connection,results几个方面: (1)修改mysql安装目录下的配置文件my.ini # The default character set that will be used when a new schema or table is # created and no character set is defined default-character-set=gbk (2)修改data目录中相应数据库目录下的db.opt配置 default-character-set=gbk default-collation=gbk_chinese_ci (3)数据库连接中指定字符集 jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=gbk", "root", "pass"); 注:useUnicode=true&characterEncoding=gbk在mysql4.1.0版中要加,5.0以上的加不加都行。 (4)在建数据库及表的时候指定字符编码为gbk 在数据库中可以用show create table tablename;show full columns from tablename;来查看字符编码形式
