用mysql 5.5.10 建数据库,插入中文数据,显示"?",怎么解决这个问题啊...
发布网友
发布时间:2022-04-23 04:17
我来回答
共2个回答
热心网友
时间:2022-05-02 05:42
用PHP的话,mysql_query("set names 'GBK'");
或直接在整理那里选 gbk_chinese_ci
还是不行的话,就改设置。
mysql> status; //查看数据库状态
--------------
c:/wamp/bin/mysql/mysql5.5.8/bin/mysql.exe Ver 14.14 Distrib 5.5.8, for Win32 (
x86)
Connection id: 2
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.8-log MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
Uptime: 1 min 44 sec
Threads: 1 Questions: 16 Slow queries: 0 Opens: 35 Flush tables: 1 Open tab
les: 28 Queries per second avg: 0.153
--------------
看到字符集是lantin1时,则需设置gbk后才能显示中文(不然显示将是一串??????)
打开MySQL配置文件my.ini,随意找块空白贴上下面四行:
[client]
default-character-set = gbk
[mysqld]
character-set-server = gbk
重启mysql,进入mysql> status; //再次查看
--------------
c:/wamp/bin/mysql/mysql5.5.8/bin/mysql.exe Ver 14.14 Distrib 5.5.8, for Win32 (
x86)
Connection id: 3
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.8-log MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: gbk
Db characterset: gbk
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
Uptime: 6 min 10 sec
Threads: 1 Questions: 19 Slow queries: 0 Opens: 35 Flush tables: 1 Open tab
les: 28 Queries per second avg: 0.51
--------------
OK,此时,已可以向数据库输入中文!
热心网友
时间:2022-05-02 07:00
1)这个是你的字符编码设置的原因,因此最好解决的方式就是把全部的东西都用同一种编码保存。举个例子来说吧,我们在公司数据库设置成 utf-8 ,php文件保存utf-8,apache 也配置成utf-8,这样就保证了字符不用转换,就省的解决乱码问题。
3)如果你要是直接像数据库里差值会出现乱码,那么你就先把数据库的表的编码设置成gbk,这样肯定不会出现乱码,因为gbk肯定没问题。
你可以去www.quzixi.com查看mysql的基础知识