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 数据库字符集问 ...
随机推荐
- 路飞学城Python-Day117
jango用户登录界面 """ Django settings for cnblog project. Generated by 'django-admin startp ...
- 51nod1072 - 威佐夫游戏【威佐夫博弈】
有2堆石子.A B两个人轮流拿,A先拿.每次可以从一堆中取任意个或从2堆中取相同数量的石子,但不可不取.拿到最后1颗石子的人获胜.假设A B都非常聪明,拿石子的过程中不会出现失误.给出2堆石子的数量, ...
- nmcli connection modify eth1 ipv4.addr "192.168.31.23" ipv4.method manual
nmcli connection modify eth1 ipv4.addr "192.168.31.23/24" ipv4.method manual 修改IP地址
- jsp js action之间传值
1.struts2 action如何向JSP的JS函数传值 action中定义变量 public class TestAction extends ActionSupport implements S ...
- struts配置
创建struts2的应用,首先应如前面所示要搭建好环境.jar包的导入和web.xml配置这里不在写出来. 如上所示,struts2中是采用<package>元素来管理Action的,包 ...
- Windows-hosts文件地址
C:\Windows\System32\drivers\etc # Copyright (c) - Microsoft Corp. # # This is a sample HOSTS file us ...
- xml与json格式互转
最近要整一些报文测试的事情,可当前项目的请求报文格式却不统一,有XML也有JSON,为了一致性,决定统一用JSON格式处理. xmltodict : Makes working with XML fe ...
- vijos- P1385盗窃-月之眼 (水题 + python)
P1385盗窃-月之眼 Accepted 标签:怪盗基德 VS OIBH[显示标签] 背景 怪盗基德 VS OIBH 第三话 描写叙述 怪盗基德第三次来到熟悉的OIBH总部.屡屡失败的OIBH这次看守 ...
- IPK僵尸网络 看看其传播手法
转自:http://www.freebuf.com/vuls/154975.html 一.IPK僵尸网络概述 IPK僵尸家族是自2012年底就开始出现并长期持续活跃在境外的DDoS僵尸网络.2016年 ...
- java.lang.ClassNotFoundException: org.objectweb.asm.ClassWriter
转自:https://www.cnblogs.com/yfceshi/p/6814802.html Caused by: javax.xml.ws.WebServiceException: java. ...