hibernate中向mysql数据库插入汉字出现???乱码问题的纠正

来源:互联网 发布:还珠颠覆知画TXT下载 编辑:程序博客网 时间:2024/05/16 09:24

如题,试过多种方法无效后,苦思中。。。

感觉自己的mysql数据库有问题,于是从官网下载后重安装了一遍,在mysql-front 插入汉字开始也出现乱码,确定是mysql自身的问题,于是修改了my.ini文件,修改代码如下(红字加粗,两处)后在mysql-front修改问题解决,而且在由hibernate向mysql写入汉字正常。\(^o^)/~

[client]


# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]


port=3306


[mysql]


default-character-set=gbk
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]


# The TCP/IP Port the MySQL Server will listen on
port=3306




#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/Program Files/MySQL/MySQL Server 5.0/"


#Path to the database root
datadir="D:/MySQL/MySQL Server 5.0/Data/"


# 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=utf8