我的MYSQL里面的中文都变成问号了?
我的MYSQL里面的中文都变成问号了,但是我写的JSP读取显示没问题,输入和输出也没问题,怎么才能是MYSQL里面的数据也是中文呢?我已经在数据库和页面都使用了UTF-8...
我的MYSQL里面的中文都变成问号了,但是我写的JSP读取显示没问题,输入和输出也没问题,怎么才能是MYSQL里面的数据也是中文呢?我已经在数据库和页面都使用了UTF-8编码了。。。谢谢各位啦。
展开
2个回答
展开全部
解决方法:
1、打开mysql安装目录下的my.ini文件,找到如下代码:
# CLIENT SECTION
# ----------------------------------------------------------------------
[client]
port=3306
[mysql]
default-character-set=latin1
# 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 Server 5.0/"
#Path to the database root
datadir="D:/Program Files/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=latin1
将default-character-set=latin1修改为:default-character-set=gb2312
2、打开hibernate配置文件,添加如下代码:
<property name="url">
jdbc:mysql://localhost/test?user=root;password=123456;useUnicode=true;characterEncoding=gbk
</property>
3、重启mysql,ok!
查找了N多资料,自己总结尝试可以,我的就是怎么解决的,如果你的问题解决了,麻烦说一声哦,祝你好运!
1、打开mysql安装目录下的my.ini文件,找到如下代码:
# CLIENT SECTION
# ----------------------------------------------------------------------
[client]
port=3306
[mysql]
default-character-set=latin1
# 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 Server 5.0/"
#Path to the database root
datadir="D:/Program Files/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=latin1
将default-character-set=latin1修改为:default-character-set=gb2312
2、打开hibernate配置文件,添加如下代码:
<property name="url">
jdbc:mysql://localhost/test?user=root;password=123456;useUnicode=true;characterEncoding=gbk
</property>
3、重启mysql,ok!
查找了N多资料,自己总结尝试可以,我的就是怎么解决的,如果你的问题解决了,麻烦说一声哦,祝你好运!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我学php的,刚开始也乱码,,就mysql主页设置下,让后就是表里设置下,在就是在代码中也设置了下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询