mysql ERROR 1366

mysql> INSERT INTO tb_room VALUES ('9101','9','1',300,'9101',0,1,'超级豪华间','public/images/rooms/single.gif',100);

ERROR 1366 (HY000): Incorrect string value: '\xB3\xAC\xBC\xB6\xBA\xC0...' for column 'RMCATALOG' at row 1

1.在mysql数据库控制台中插入数据的时候出现如下错误

2.原因是插入的数据中包含了中文字符

我们首先使用status命令查看数据库字符街状态如下:

然后使用set names gbk;修改字符集为gbk,最后就可以成功插入中文字符了。

查看mysql数据库及表编码格式

1.查看数据库编码格式

mysql> show variables like 'character_set_database';

2.查看数据表的编码格式

mysql> show create table <表名>;

3.创建数据库时指定数据库的字符集

mysql>create database <数据库名> character set utf8;

4.创建数据表时指定数据表的编码格式

create table tb_books (
name varchar(45) not null,
price double not null,
bookCount int not null,
author varchar(45) not null
) default charset = utf8;

5.修改数据库的编码格式

mysql>alter database <数据库名> character set utf8;

6.修改数据表格编码格式

mysql>alter table <表名> character set utf8;

7.修改字段编码格式

mysql>alter table <表名> change <字段名> <字段名> <类型> character set utf8;
mysql>alter table user change username username varchar(20) character set utf8 not null;

8.添加外键

mysql>alter table tb_product add constraint fk_1 foreign key(factoryid) references tb_factory(factoryid);
mysql>alter table <表名> add constraint <外键名> foreign key<字段名> REFERENCES <外表表名><字段名>;

9.删除外键

mysql>alter table tb_people drop foreign key fk_1;
mysql>alter table <表名> drop foreign key <外键名>;

参考资料:

mysql ERROR 1366的更多相关文章

  1. Linux MySQl 5.7.17 MySQL ERROR 1366(HY000):Incorrect string value 解决方法

    MySQL ERROR 1366(HY000):Incorrect string value,在往数据库中插入中文的时候会出现. 这也就是编码问题,网上大部分都是说设置下配置文件中的设置,而可悲的是在 ...

  2. MySQL ERROR 1366(HY000) Incorrect string value

    有以下两张表: mysql> show tables; +---------------+ | Tables_in_old | +---------------+ | book | | pres ...

  3. mysql 插入中文时出现ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern ame' at row 1

    1 环境: MySQL Server 6.0  命令行工具 2 问题 :  插入中文字符数据出现如下错误: ERROR 1366 (HY000): Incorrect string value: '\ ...

  4. mysql insert中文乱码无法插入ERROR 1366 (HY000): Incorrect string value

    ERROR 1366 (HY000): Incorrect string value: '\xB1\xEA\xCC\xE2\xD5\xE2...' for column 'title' at row ...

  5. mysql输入中文出现ERROR 1366

    MySQL输入中文出现如下错误: ERROR 1366: 1366: Incorrect string value: '\xE6\xB0\xB4\xE7\x94\xB5...' for column ...

  6. MySQL学习笔记04 插入中文时出现ERROR 1366 (HY000)

    1 环境: MySQL Server 6.0  命令行工具 2 问题 :  插入中文字符数据出现如下错误: ERROR 1366 (HY000): Incorrect string value: '\ ...

  7. Mysql插入中文时提示:ERROR 1366 (HY000): Incorrect string value: '\xE5\x8F\xB0\xE5\xBC\x8F...' fo

    Mysql插入数据时提示:ERROR 1366 (HY000): Incorrect string value: ‘\xE5\x8F\xB0\xE5\xBC\x8F…’ fo 分析如下: 首先通过语句 ...

  8. mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumiaoshu' at row 1 解决方法

    mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumi ...

  9. ERROR 1366 (HY000): Incorrect string value: '\xE9\x83\x91\xE5\xB7\x9E' for column 'aa' at row 1 MySQL 字符集

    ERROR 1366 (HY000): Incorrect string value: '\xE9\x83\x91\xE5\xB7\x9E' for column 'aa' at row 1创建表之后 ...

随机推荐

  1. C#学习目录处理

    目录获取和处理: string path = ".";//表明要在当前所在的目录 //先定义目录信息变量 DirectoryInfo dir = new DirectoryInfo ...

  2. [LeetCode] 17. Letter Combinations of a Phone Number ☆☆

    Given a digit string, return all possible letter combinations that the number could represent. A map ...

  3. 数据结构&字符串:字典树

    前缀树里面可以存一堆字符串,也可以说是一堆单词,存完之后我们可以轻松判断一个指定的字符串是否出现过 下面我来详细解释一下实现细节 *+; //单词个数*每一个单词的字符数 ; struct Trie ...

  4. LightOJ 1341 - Aladdin and the Flying Carpet 基本因子分解

    http://www.lightoj.com/volume_showproblem.php?problem=1341 题意:给你长方形的面积a,边最小为b,问有几种情况. 思路:对a进行素因子分解,再 ...

  5. WCF 同一个解决方案中控制台应用添加服务引用报错

    错误提示: “Unable to check out the current file. The file may be read-only or locked, or you may need to ...

  6. 多重部分和问题 (dp)

    题目描述 有n种不同大小的数字Ai,每种各Mi个.判断是否能从这些数字中选出若干个使它们的和恰好为K. 这个问题可以用DP求解,递推关系式的定义会影响最终的复杂度. 第一种定义: dp[i+1][j] ...

  7. chromedriver版本 支持的Chrome版本

    在使用selenium测试时,如果选择chrome浏览器,需要将chrome driver的exe文件放在项目下 错误的driver版本,会导致无法正常打开本机的浏览器 以下为对应关系 来自网络 ch ...

  8. 25个Linux相关的网站【转】

    转自:http://www.cnblogs.com/Lindaman/p/4552805.html 下面是25个最具有影响力,也是最重要的Linux网站,这些网站提供了Linux的分发包,软件,文件, ...

  9. 学习 Linux,101: 自定义或编写简单脚本【转】

    转自:http://www.ibm.com/developerworks/cn/linux/l-lpic1-105-2/index.html 学习如何使用标准的 shell 语法.循环和控制结构,以及 ...

  10. nfs 文件共享 服务

    需要rpc服务: [root@xujiaxuan ftp]# service rpcbind start[root@xujiaxuan ftp]# chkconfig rpcbind on 设置开机自 ...