MySQL无法显示中文,编码设成utf-8也不行!

MySQL5.0.18无法显示中文,编码设成utf-8也不行!
mysql> create table aaa(name varchar(20));
Query OK, 0 rows affected (0.10 sec)

mysql> show create table aaa;
+-------+--------------------------------------------------------
| Table | Create Table
+-------+--------------------------------------------------------
| aaa   | CREATE TABLE `aaa` (
  `name` varchar(20) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------
1 row in set (0.00 sec)

mysql> insert into aaa values('你在哪里啊?');
ERROR 1406 (22001): Data too long for column 'name' at row 1
mysql> insert into aaa values('你在');
ERROR 1406 (22001): Data too long for column 'name' at row 1
mysql> insert into aaa values('你');
ERROR 1406 (22001): Data too long for column 'name' at row 1
mysql>

之后我又试了set session sql_mode='';能插入,但是无法正常显示,五六个的中文汉字结果只能显示出一两个乱码!

再之后,我安装了mysql 5.1.34 下,我所用的编码方式为utf-8,结果与上不同,但一样不支持中文,只有在gbk和gb2312下才能插入并显示正确:

mysql> 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       | D:\Java\MySQL5\share\charsets\ |
+--------------------------+--------------------------------+
8 rows in set (0.00 sec)

mysql> create table a(name varchar(10));
Query OK, 0 rows affected (0.07 sec)

mysql> insert into a values('完全');
ERROR 1366 (HY000): Incorrect string value: '\xCD\xEA\xC8\xAB' for column 'name' at row 1
mysql> set session sql_mode='';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into a values('完全');
Query OK, 1 row affected, 1 warning (0.04 sec)

mysql> select * from a;
+------+
| name |
+------+
|      |
+------+
1 row in set (0.00 sec)

mysql> set names gbk;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into a values('完全');
Query OK, 1 row affected (0.05 sec)

mysql> select * from a;
+------+
| name |
+------+
|      |
| 完全    |
+------+
2 rows in set (0.02 sec)

mysql>


极度郁闷中。。。

你可能感兴趣的:(mysql 中文 utf-8)