数据表插入中文时出现以下报错
mysql> INSERT test8 VALUES(1 ,'小明');
ERROR 1366 (HY000): Incorrect string value: '\xC3\xF7' for column 'name'
这个是一般是编码格式错了,可以改成中文编码再尝试
mysql> set character_set_client=gbk;
mysql> INSERT user6 VALUES(1 ,'小明');
Query OK, 1 row affected (0.11 sec)
这时插入成功,但是查询表现实的是中文乱码
mysql> SELECT * FROM user6;
+------+--------+
| id | name |
+------+--------+
| 1 | 灏忔槑 |
+------+--------+
1 row in set (0.00 sec)
还需要做一些设置
set character_set_connection=gbk;
set character_set_database=utf8;
set character_set_server=utf8;
set character_set_results=gbk;
现在显示正常中文了,但是表格边框不是对齐的
mysql> SELECT * FROM user6;
+------+------+
| id | name |
+------+------+
| 1 | 小明 |
+------+------+
1 row in set (0.00 sec)
最后改一下字符集
mysql> charset gbk;
Charset changed
mysql> SELECT * FROM user6;
+----+------+
| id | name |
+----+------+
| 1 | 小明 |
+----+------+
1 row in set (0.00 sec)
终于弄好了,这个问题查了好久,尝试了很多方法才解决好,自己真是渣渣水平o(╥﹏╥)o