标签:bsp ogr 你好 更改 style column nod mysql中文乱码 今天
mysql> create table test( -> id int, -> name varchar(20), -> primary key(id) -> ); Query OK, 0 rows affected (0.06 sec) mysql> insert into test(id, name) values(1, "你好"); ERROR 1366 (HY000): Incorrect string value: ‘\xC4\xE3\xBA\xC3‘ for column ‘name‘ at row 1
mysql> show create table test \G; *************************** 1. row *************************** Table: test Create Table: CREATE TABLE `test` ( `id` int(11) NOT NULL DEFAULT ‘0‘, `name` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec)
创建另一个测试用表,指定编码格式
mysql> CREATE TABLE XXX( -> `id` int(11) NOT NULL DEFAULT ‘0‘, -> `name` varchar(20) DEFAULT NULL, -> PRIMARY KEY (`id`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf-8 -> ; mysql> insert into XXX(id, name) values(1, "你好"); Query OK, 1 row affected (0.01 sec)
mysql> create database mydb character set utf8; Query OK, 1 row affected (0.00 sec)
mysql> show variables like "%char%"; +--------------------------+---------------------------------------------------------+ | Variable_name | Value | +--------------------------+---------------------------------------------------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.6\share\charsets\ | +--------------------------+---------------------------------------------------------+ 8 rows in set (0.00 sec)
mysql> set character_set_server=utf8; mysql> set character_set_database=utf8; Query OK, 0 rows affected (0.00 sec) mysql> show variables like "%char%"; +--------------------------+---------------------------------------------------------+ | 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 | C:\Program Files\MySQL\MySQL Server 5.6\share\charsets\ | +--------------------------+---------------------------------------------------------+ 8 rows in set (0.00 sec)
[mysqld] character-set-server=utf8 collation-server=utf8_general_ci [mysql] default-character-set=utf8
mysql> show variables like "%char%"; +--------------------------+---------------------------------------------------------+ | 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 | C:\Program Files\MySQL\MySQL Server 5.6\share\charsets\ | +--------------------------+---------------------------------------------------------+ 8 rows in set (0.00 sec)
标签:bsp ogr 你好 更改 style column nod mysql中文乱码 今天
原文地址:https://www.cnblogs.com/AbbieChen/p/9763794.html