读mysql数据库中的中文乱码
3h随然吧 2010-04-29 05:42:31 原有数据库和表都是GBK编码的,我用mysql console 显示中文没有问题,但我使用mysql workbench GUI tools和拿vc程序读都是乱码。它们俩中文乱码是不一样的,workbench GUI 中数据本身没有问题,只是它说是需要UTF8编码,所以就乱码了。而vc程序读中文数据,把中文本身的编码都乱套了,后面全是问号(?)。
网上搜集了很多的资料,基本可以确定为字符集的问题。但把字符集设个遍还是搞不定。都搞了好几天了,还是不行,哪位高手帮忙解决下!谢谢!
mysql及数据库中的数据的详细信息如下:
mysql> show variables like 'char%';
+--------------------------+----------------------------------------------------
-----+
| Variable_name | Value
|
+--------------------------+----------------------------------------------------
-----+
| character_set_client | gbk
|
| character_set_connection | gbk
|
| character_set_database | gbk
|
| character_set_filesystem | binary
|
| character_set_results | gbk
|
| character_set_server | gbk
|
| character_set_system | utf8
|
| character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.1\share\chars
ets\ |
+--------------------------+----------------------------------------------------
-----+
mysql> show variables like 'collation%';
+----------------------+----------------+
| Variable_name | Value |
+----------------------+----------------+
| collation_connection | gbk_chinese_ci |
| collation_database | gbk_chinese_ci |
| collation_server | gbk_chinese_ci |
+----------------------+----------------+
3 rows in set (0.00 sec)
mysql> show create table beijing;
+---------+---------------------------------------------------------------------
| Table | Create Table
| beijing | CREATE TABLE `beijing` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varbinary(255) NOT NULL DEFAULT '
' COMMENT '????¤??????
??',
`level` tinyint(3) NOT NULL DEFAULT '0',
`parent` varbinary(64) DEFAULT '-1
',
`pcid` int(11) unsigned NOT NULL DEFAULT '0',
`longtitude` int(11) DEFAULT '-1' COMMENT '????(NTU)',
`latitude` int(11) DEFAULT '-1' COMMENT '????(NTU)',
`geo` varchar(100) NOT NULL DEFAULT '',
`admincode` int(11) unsigned NOT NULL DEFAULT '0',
`cid` int(11) unsigned NOT NULL DEFAULT '0',
`next` int(11) unsigned DEFAULT '0' COMMENT '??????????????CID',
`cityid` smallint(6) NOT NULL DEFAULT '0' COMMENT '?????¨°??',
`valid` tinyint(3) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `CIDIndex` (`cid`),
KEY `NameIndex` (`name`),
KEY `level_index` (`level`),
KEY `admincode_index` (`admincode`),
KEY `pcid_index` (`pcid`),
KEY `parent_index` (`parent`),
KEY `cityid_index` (`cityid`)
) ENGINE=InnoDB AUTO_INCREMENT=346454 DEFAULT CHARSET=gbk COMMENT='????' |