数据库
show create database game2 \G
Database: game2
Create Database: CREATE DATABASE `game2` /*!40100 DEFAULT CHARACTER SET utf8 */表
show create table test \G
Table: test
Create Table: CREATE TABLE `test` (
`name` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8当前环境字符编码
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 |上面是我当前环境的说明,不知道是否还有缺漏之处。
我的问题很简单,就是插入特殊字符,始终插入不进去,如下语句:
insert into test(name) values('');
执行后总是报如下错误:
ERROR 1366 (HY000): Incorrect string value: '\xA7\xCD' for column 'name' at row1说明:我把上面的utf8全改成gbk,就可以插入,但是我想知道为什么用utf8反而不行。
show create database game2 \G
Database: game2
Create Database: CREATE DATABASE `game2` /*!40100 DEFAULT CHARACTER SET utf8 */表
show create table test \G
Table: test
Create Table: CREATE TABLE `test` (
`name` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8当前环境字符编码
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 |上面是我当前环境的说明,不知道是否还有缺漏之处。
我的问题很简单,就是插入特殊字符,始终插入不进去,如下语句:
insert into test(name) values('');
执行后总是报如下错误:
ERROR 1366 (HY000): Incorrect string value: '\xA7\xCD' for column 'name' at row1说明:我把上面的utf8全改成gbk,就可以插入,但是我想知道为什么用utf8反而不行。
insert into test(name) values('');
MySQL 中文显示乱码
试过了的,普通的汉字字符什么的都可以插入成功,但是insert into test(name) values('');
这个插入的是一个特殊字符,我也不知道是什么,它就是插入不进去。这个字符用户可以通过输入法输入,所以程序里面在插入的时候会报错。我想解决如何让这个特殊字符能够顺利插入进去。ACMAIN_CHM你试下把表和库的字符编码设置成utf8,看能不能执行我这条语句。