MySQL ERROR 1366(HY000) Incorrect string value
有以下两张表:
mysql> show tables;
+---------------+
| Tables_in_old |
+---------------+
| book |
| press |
+---------------+
2 rows in set (0.00 sec)
mysql> desc book;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(10) | YES | UNI | NULL | |
| press_id | int(11) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> desc press;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(10) | YES | UNI | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
在往表里插数据时报错了:
mysql> insert into press(name) values
-> ('北京工业地雷出版社'),
-> ('人民音乐不好听出版社'),
-> ('知识产权没有用出版社')
-> ;
ERROR 1366 (HY000): Incorrect string value: '\xE5\x8C\x97\xE4\xBA\xAC...' for column 'name' at row 1
不支持中文,查看下字符编码:
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| 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)
发现database的字符编码是latin1,修改字符编码:
mysql> SET CHARACTER_SET_DATABASE=utf8;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> 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 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
现在看起来修改过来了,现在插入数据:
mysql> insert into press(name) values
-> ('北京工业地雷出版社'),
-> ('人民音乐不好听出版社'),
-> ('知识产权没有用出版社')
-> ;
ERROR 1366 (HY000): Incorrect string value: '\xE5\x8C\x97\xE4\xBA\xAC...' for column 'name' at row 1
发现还是报错,最直接的办法是删库跑路!!!!
不过需要查看当前库的字符编码,然后修改。
MySQL ERROR 1366(HY000) Incorrect string value的更多相关文章
- Linux MySQl 5.7.17 MySQL ERROR 1366(HY000):Incorrect string value 解决方法
MySQL ERROR 1366(HY000):Incorrect string value,在往数据库中插入中文的时候会出现. 这也就是编码问题,网上大部分都是说设置下配置文件中的设置,而可悲的是在 ...
- 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: '\ ...
- 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 ...
- 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 分析如下: 首先通过语句 ...
- 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创建表之后 ...
- ERROR 1366 (HY000): Incorrect string value:MySQL数据库、表的字符集为GBK
mysql> update userinfo set MEDIASOURCE = 'CS02-北京' where IMPORTNO = 'IMP201640613101206';ERROR 13 ...
- mysql DOS中中文乱码 ERROR 1366 (HY000): Incorrect string value: '\xC4\xEA\xBC\xB6' for column 'xxx' at row 1
问题:ERROR (HY000): Incorrect string value: 在DOS中插入或查询中文出现乱码 登入mysql,输入命令:show variables like '%char%' ...
- ERROR 1366 (HY000): Incorrect string value: '\xD6\xD0\xCE\xC4' for column XXX at row 1
本错误为:该列的插入格式有误 修改该表中该列的字符集为utf-8 网上办法: )不能插入中文解决办法: 向表中插入中文然后有错误. mysql> insert into users values ...
- 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 数据库字符集问 ...
随机推荐
- Windows GUI程序自动化之pywinauto
一. pywinauto知识点总结 官方英文版文档网址:https://pywinauto.readthedocs.io/en/latest/index.html 1.1 pywinauto的安装与配 ...
- nyoj14-会场安排问题
会场安排问题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办.小刘的工作就 ...
- k8s的概念
Kubernetes(简称为 K8s),最初由 Google 的工程师开发和设计.Kubernetes 是用于自动部署.扩展和管理容器化应用程序的开源系统,它旨在提供跨主机集群的自动部署.扩展以及运行 ...
- 用Python图像处理
前几天弄了下django的图片上传,上传之后还需要做些简单的处理,python中PIL模块就是专门用来做这个事情的. 于是照葫芦画瓢做了几个常用图片操作,在这里记录下,以便备用. 这里有个字体文件,大 ...
- oracle 创建自增主键
1.创建表 create table Test_Increase( userid number(10) NOT NULL primary key, /*主键,自动增加*/ username varch ...
- springmvc中配置拦截器
-------------------------------------------- 登陆controller方法 @Controller public class LoginController ...
- MyBatis-Spring-SqlSessionFactoryBean(转)
SqlSessionFactoryBean 在基本的 MyBatis 中,session 工厂可以使用 SqlSessionFactoryBuilder 来创建.而在 MyBatis-Spring 中 ...
- COCOS2DX 3.0 优化提升渲染速度 Auto-batching
COCOS2DX 3.0 优化提升渲染速度 Auto-batching 近期在看COCOS2DX 3.0的Auto-batching合批与Auto Culling动态缩减功能以下就来细致看看吧:整合好 ...
- 沃通SSL精灵,让站点HTTPS永只是期
告别HTTP明文"裸奔"时代 百度.阿里巴巴.必应等越来越多的互联网巨头相继启用全站HTTPS加密,保护用户数据和隐私安全.逐步告别HTTP明文"裸奔"时代. ...
- 远程视频监控之驱动篇(LED)
转载请注明出处:http://blog.csdn.net/ruoyunliufeng/article/details/38515205 之前一直在考虑该不该写这篇,由于我之前在博客里有写过LED的驱动 ...