我的MYSQL里面的中文都变成问号了?

2024-12-14 14:03:46
推荐回答(2个)
回答1:

解决方法:

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配置文件,添加如下代码:


jdbc:mysql://localhost/test?user=root;password=123456;useUnicode=true;characterEncoding=gbk


3、重启mysql,ok!

查找了N多资料,自己总结尝试可以,我的就是怎么解决的,如果你的问题解决了,麻烦说一声哦,祝你好运!

回答2:

我学php的,刚开始也乱码,,就mysql主页设置下,让后就是表里设置下,在就是在代码中也设置了下