解决方法:
1、打开mysql安装目录下的myini文件,找到如下代码:
# 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 50/"
#Path to the database root
datadir="D:/Program Files/MySQL Server 50/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/testuser=root;password=123456;useUnicode=true;characterEncoding=gbk
</property>
3、重启mysql,ok!
查找了N多资料,自己总结尝试可以,我的就是怎么解决的,如果你的问题解决了,麻烦说一声哦,祝你好运!
乱码有三种
1:数据库方面不匹配,数据库有字符集的,不知道你mysql用的什么工具,phpadmin?你可以查看一下数据库的编码方式。
2:php代码设置mysql_query("SET NAMES 'gbk'"); 就是这个
3:你页面当前使用的编码方式,IE模式下面,右键-编码方式,或者 <meta >
首先你要搞清楚,插入到数据库的字符是乱码,如果是,则需要在插入数据库之前,进行字符编码转换。如果是通过WEB程序插入,则需要在WEB层设置字符格式和转换。如果数据库中不是乱码,在查询显示的时候是乱码,则需要跟踪,看信息在哪里交互的时候出现了乱码,设置转换即可。
比如,WEB应用,在JSP 里面 设置 <%@ page language="java" import="javautil" pageEncoding="GBK"%>
以上就是关于我的MYSQL里面的中文都变成问号了全部的内容,包括:我的MYSQL里面的中文都变成问号了、php 插入到mysql数据库的中文是问号肿么解决、导入mysql数据库后中文全部变成问号,英文变大写等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)