首页 > 代码库 > ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'name' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'name' at row 1
ERROR 1366 (HY000): Incorrect string value: ‘\xD5\xC5\xC8\xFD‘ for column ‘name‘
at row 1
数据库字符集问题,查看数据库状态:
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.6.12, for Win32 (x86)
Connection id: 25
Current database: information_schema
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.12 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
Uptime: 8 hours 54 min 47 sec
Threads: 1 Questions: 372 Slow queries: 0 Opens: 108 Flush tables: 1 Open t
ables: 62 Queries per second avg: 0.011
--------------
我要使用的库test的字符集是latin1,该字符集不支持中文字符。
查看表引擎状态:
mysql> show create table ttt;
+-------+-----------------------------------------------------------------------
-----------------------------------------------------------------------+
| Table | Create Table
|
+-------+-----------------------------------------------------------------------
-----------------------------------------------------------------------+
| ttt | CREATE TABLE `ttt` (
`id` int(11) NOT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------
-----------------------------------------------------------------------+
修改表字符集:
mysql> alter table ttt character set utf8;
Query OK, 0 rows affected (0.10 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table ttt;
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
----------+
| Table | Create Table
|
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
----------+
| ttt | CREATE TABLE `ttt` (
`id` int(11) NOT NULL,
`name` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
----------+
修改字段字符集:
mysql> alter table ttt modify name varchar(20) character set utf8;
Query OK, 0 rows affected (1.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table ttt;
+-------+-----------------------------------------------------------------------
---------------------------------------------------------------------+
| Table | Create Table
|
+-------+-----------------------------------------------------------------------
---------------------------------------------------------------------+
| ttt | CREATE TABLE `ttt` (
`id` int(11) NOT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-----------------------------------------------------------------------
---------------------------------------------------------------------+
1 row in set (0.02 sec)
OK!
转载出处 http://blog.sina.com.cn/s/blog_8f7940400101by3u.html
ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'name' at row 1
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。