请问一个编码的问题 有一个不带中文的文件,类型为ASCII english text,在里面手动加入中文后,用file命令发现类型变为ISO-8859 text,然后用iconv转码为utf-8之后,utf-8的处理端就无法识别了,我把LANG环境变量清空了,设置为zh_CN.UTF-8或者en_US.UTF-8或者纯粹UTF-8都没用,不知道这个怎么处理? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在Secure CRT里面设置了,但是在执行sql时会报Res: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation '=';show variables like 'character%';结果为:+--------------------------+----------------------------------------+| Variable_name | Value |+--------------------------+----------------------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |+--------------------------+----------------------------------------+show variables like "%coll%";结果为:+----------------------+-----------------+| Variable_name | Value |+----------------------+-----------------+| collation_connection | utf8_general_ci || collation_database | utf8_general_ci || collation_server | utf8_general_ci |+----------------------+-----------------+查询表结构为:| source | CREATE TABLE `source` ( `id` int(11) NOT NULL AUTO_INCREMENT, `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `lastmodifyTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `creator` smallint(6) NOT NULL, `content` varchar(255) NOT NULL, `default1` tinyint(4) DEFAULT NULL, `default2` smallint(6) DEFAULT NULL, `default3` int(11) DEFAULT NULL, `default4` double DEFAULT NULL, `default5` date DEFAULT NULL, `default6` varchar(255) DEFAULT NULL, `default7` text, `default8` tinyint(1) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 |每个字段类型为:-----------+---------------------------------+---------+| id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | || createTime | timestamp | NULL | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | select,insert,update,references | || lastmodifyTime | timestamp | NULL | NO | | 0000-00-00 00:00:00 | | select,insert,update,references | || creator | smallint(6) | NULL | NO | | NULL | | select,insert,update,references | || content | varchar(255) | utf8_general_ci | NO | | NULL | | select,insert,update,references | || default1 | tinyint(4) | NULL | YES | | NULL | | select,insert,update,references | || default2 | smallint(6) | NULL | YES | | NULL | | select,insert,update,references | || default3 | int(11) | NULL | YES | | NULL | | select,insert,update,references | || default4 | double | NULL | YES | | NULL | | select,insert,update,references | || default5 | date | NULL | YES | | NULL | | select,insert,update,references | || default6 | varchar(255) | utf8_general_ci | YES | | NULL | | select,insert,update,references | || default7 | text | utf8_general_ci | YES | | NULL | | select,insert,update,references | || default8 | tinyint(1) | NULL | YES | | NULL | | select,insert,update,references | |+----------------+--------------+-----------------+------+-----+---------------------+------------------ms没有gbk编码的内容啊,环境变量LANG的值为UTF-8 如果mysql在编译时没有将gbk编译进去,那就需要重新编译mysql了--with-charset=gbk --with-extra-charsets=all 奇怪了,我已经用iconv把中文转为utf-8编码了 文件中的中文在入库时会报Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gbk_chinese_ci,COERCIBLE) for operation '=',但是从文件类型上看,从文件内容上看都没有问题。 即然有中文,就把编码 统一成 utf-8啊 使用show charset来dump出字符集gbk | GBK Simplified Chinese | gbk_chinese_ci | 2有gbk啊 将文件重新保存一下,编码选择utf-8 ! 你用的linux?实在拿不定把握,切到windows下,使用notepad++,把文件转存成utf-8格式的,再弄过去执行试试。 mysql远程导入的问题 300Msql文件导入到mysql 出现的问题 mysql ID自动增加不够用怎么办 数据库查询求助 邮箱数据库 mysql 如何使用GB18030字符集? MYSQL数据无法同步。 >>>建立表格时将多个字段设置为主键的sql语句怎么写??<<<< 我想用php+mysql做一个在线做作业批改作业的系统 mysql的缓存配置 一个mysql的问题,想支付酬劳请人帮忙处理下,多谢。 使用64位mysql Prepared Statements问题
show variables like 'character%';结果为:
+--------------------------+----------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |
+--------------------------+----------------------------------------+
show variables like "%coll%";结果为:
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+----------------------+-----------------+
查询表结构为:
| source | CREATE TABLE `source` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lastmodifyTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`creator` smallint(6) NOT NULL,
`content` varchar(255) NOT NULL,
`default1` tinyint(4) DEFAULT NULL,
`default2` smallint(6) DEFAULT NULL,
`default3` int(11) DEFAULT NULL,
`default4` double DEFAULT NULL,
`default5` date DEFAULT NULL,
`default6` varchar(255) DEFAULT NULL,
`default7` text,
`default8` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
每个字段类型为:
-----------+---------------------------------+---------+
| id | int(11) | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
| createTime | timestamp | NULL | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | select,insert,update,references | |
| lastmodifyTime | timestamp | NULL | NO | | 0000-00-00 00:00:00 | | select,insert,update,references | |
| creator | smallint(6) | NULL | NO | | NULL | | select,insert,update,references | |
| content | varchar(255) | utf8_general_ci | NO | | NULL | | select,insert,update,references | |
| default1 | tinyint(4) | NULL | YES | | NULL | | select,insert,update,references | |
| default2 | smallint(6) | NULL | YES | | NULL | | select,insert,update,references | |
| default3 | int(11) | NULL | YES | | NULL | | select,insert,update,references | |
| default4 | double | NULL | YES | | NULL | | select,insert,update,references | |
| default5 | date | NULL | YES | | NULL | | select,insert,update,references | |
| default6 | varchar(255) | utf8_general_ci | YES | | NULL | | select,insert,update,references | |
| default7 | text | utf8_general_ci | YES | | NULL | | select,insert,update,references | |
| default8 | tinyint(1) | NULL | YES | | NULL | | select,insert,update,references | |
+----------------+--------------+-----------------+------+-----+---------------------+------------------
ms没有gbk编码的内容啊,环境变量LANG的值为UTF-8
--with-charset=gbk --with-extra-charsets=all
gbk | GBK Simplified Chinese | gbk_chinese_ci | 2
有gbk啊
实在拿不定把握,切到windows下,使用notepad++,把文件转存成utf-8格式的,再弄过去执行试试。