An error is reported when inserting Chinese Characters in MySQL. For details, refer to the analysis below. Incorrectstringvalue: xD0xC2xC8AxBEWforcolumnctnratrow1MySQL character set parameters: character_set_server: Server Character Set collation_server: Server verification rule character_set_database: Default
An error is reported when inserting Chinese Characters in MySQL. For details, refer to the analysis below. Incorrect string value: '\ xD0 \ xC2 \ xC8A \ xbew' for column 'ctnr' at row 1 MySQL character set parameters: character_set_server: Server Character Set collation_server: Server verification rule character_set_database: Default
An error is reported when inserting Chinese Characters in MySQL. For details, refer to the analysis below.
Incorrect string value: '\ xD0 \ xC2 \ xC8A \ xbew' for column 'ctnr' at row 1
MySQL character set parameters:
Character_set_server: Server Character Set
Collation_server: Server verification rules
Character_set_database: Character Set of the default database
Collation_database: the default database proofreading rules
Character_set_client: the server uses this variable to obtain the character set of the client in the link.
Character_set_connection: the server converts the query of the client from character_set_client to the character set specified by this variable.
Character_set_results: the character set specified by the variable before the server sends the result set or returns an error message to the client.
You can set the concatenation character set in two statements:
A
Set names 'charset _ name' is equivalent to the following three sentences:
Mysql> SET character_set_client = x;
Mysql> SET character_set_results = x;
Mysql> SET character_set_connection = x; # This also sets the default value of collation_connection x
B
Set character set charset_name is equivalent to the following three sentences:
Mysql> SET character_set_client = x;
Mysql> SET character_set_results = x;
Mysql> SET collation_connection =collation_database;
When character_set_results is NULL, the server does not convert the returned result set.
Mysql> SET character_set_results = NULL;
The error reported by pg due to character set encoding is: invalid byte sequence for encoding "UTF8". for details, refer
Http://blog.csdn.net/beiigang/article/details/39582583
Problem caused by character set encoding on MySQL: Incorrect string value. For details, see the following experiment:
1
Mysql> show variables like '% character_set % ';
+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | gbk |
| Character_set_connection | gbk |
| Character_set_database | utf8 |
| Character_set_filesystem | binary |
| Character_set_results | gbk |
| Character_set_server | utf8 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
8 rows in set (0.00 sec)
2
Mysql> create table tb_tt (id int, ctnr varchar (60 ));
Query OK, 0 rows affected (0.06 sec)
3
Mysql> show create table tb_tt;
+ ------- + -----------------------------------------------------------------------
----------------------------------------------------- +
| Table | Create Table
|
+ ------- + -----------------------------------------------------------------------
----------------------------------------------------- +
| Tb_tt | create table 'tb _ tt '(
'Id' int (11) default null,
'Ctnr 'varchar (60) DEFAULT NULL
) ENGINE = InnoDB default charset = utf8 |
+ ------- + -----------------------------------------------------------------------
----------------------------------------------------- +
1 row in set (0.00 sec)
4
Mysql> insert into tb_tt (id, ctnr) values (1, 'new extranet ');
Query OK, 1 row affected (0.02 sec)
5
Mysql> select * from tb_tt;
+ ------ + -------- +
| Id | ctnr |
+ ------ + -------- +
| 1 | new website |
+ ------ + -------- +
1 row in set (0.02 sec)
6
Mysql> set names 'utf8 ';
Query OK, 0 rows affected (0.00 sec)
7
Mysql> show variables like '% character_set % ';
+ -------------------------- + ---------------------------- +
| 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 |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
8 rows in set (0.00 sec)
8
Mysql> insert into tb_tt (id, ctnr) values (2, 'new extranet ');
ERROR 1366 (HY000): Incorrect string value: '\ xD0 \ xC2 \ xC8A \ xbew' for column 'ctnr' at row 1
9
If you change the default character set or collation for a database,
Stored routines that use the database defaults must be dropped and
Recreated so that they use the new ults. (In a stored routine,
Variables with character data types use the database defaults if
Character set or collation are not specified explicitly. See [HELP
Create procedure].)
Refer:
Http://dev.mysql.com/doc/refman/5.5/en/globalization.html
Http://dev.mysql.com/doc/refman/5.5/en/alter-database.html
-----------------
Blog.csdn.net/beiigang