mysql> create table a (name varchar(32));
Query OK, 0 rows affected (0.50 sec)mysql> insert into a values ('aaaaaa');
Query OK, 1 row affected (0.03 sec)mysql> insert into a values ('妹妹美');
Query OK, 1 row affected (0.06 sec)mysql> select count(distinct name) from a;
+----------------------+
| count(distinct name) |
+----------------------+
| 1 |
+----------------------+
1 row in set (0.05 sec)mysql>高手看看,只是为什么?为什么'aaaaaa'等于'妹妹美'?我竟以为count出来应该是2.
Query OK, 0 rows affected (0.50 sec)mysql> insert into a values ('aaaaaa');
Query OK, 1 row affected (0.03 sec)mysql> insert into a values ('妹妹美');
Query OK, 1 row affected (0.06 sec)mysql> select count(distinct name) from a;
+----------------------+
| count(distinct name) |
+----------------------+
| 1 |
+----------------------+
1 row in set (0.05 sec)mysql>高手看看,只是为什么?为什么'aaaaaa'等于'妹妹美'?我竟以为count出来应该是2.
mysql> select * from a;
+--------+
| name |
+--------+
| aaaaaa |
| 妹妹美 |
+--------+
2 rows in set (0.00 sec)mysql>查询结果显示确实有两条记录。第二条记录应该没有插入失败
Query OK, 0 rows affected (0.00 sec)mysql> insert into a values ('妹妹美');
ERROR 1366 (HY000): Incorrect string value: '\xC3\xC3\xC3\xC3\xC3\xC0' for colum
n 'name' at row 1
mysql>在设置成utf8后,插入中文数据又有错了。
Query OK, 0 rows affectedmysql> insert into a values ('aaaaaa');
Query OK, 1 row affectedmysql> insert into a values ('妹妹美');
Query OK, 1 row affectedmysql> select count(distinct name) from a;
+----------------------+
| count(distinct name) |
+----------------------+
| 2 |
+----------------------+
1 row in setmysql> set names gbk;
Query OK, 0 rows affectedmysql> select count(distinct name) from a;
+----------------------+
| count(distinct name) |
+----------------------+
| 2 |
+----------------------+
1 row in setmysql> set names utf8;
Query OK, 0 rows affectedmysql> select count(distinct name) from a;
+----------------------+
| count(distinct name) |
+----------------------+
| 2 |
+----------------------+
1 row in setmysql> set names gb2312;
Query OK, 0 rows affectedmysql> select count(distinct name) from a;
+----------------------+
| count(distinct name) |
+----------------------+
| 2 |
+----------------------+
1 row in set
mysql> select version();
+---------------------+
| version() |
+---------------------+
| 5.0.22-community-nt |
+---------------------+
1 row in setmysql> 最后是我的版本,我觉得你的环境有问题,对于中文的编码可能性很大。
http://topic.csdn.net/u/20100705/21/c101b33f-2abf-447e-a4e6-0e322834e99f.html?seed=1645605709&r=66769697#replyachor大家帮忙看看问题所在吧。想得头皮发麻了。恼火恼火
导出的sql文件是ANSI的,你可用工具软件查看编码类型,也可用记事本打开并在“另存为”对话框中查看
你可以用工具或自编程序将sql文件的编码转换成你的数据库要求的编码
注意后面的bin