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 2
MYSQL经典问题:
(ERROR 1366 (HY000): Incorrect string value:'\xD5\xD4' for column 'name' at row 1)
网上有好多解决中文乱码的贴, 大致都讲的是修改 %MYSQL_DIR%/my.ini default-character-set=gbk 什么的
我试过了, 不起作用. (可能是我没处理到位)
下面是我琢磨了半天,得到的结果, 不知道是否值得提倡, 但目的绝对达到了:
登陆mysql --->
进入相应数据库--->
输入命令: show variables like '%char%';
得到:
+--------------------------+--------------------------+
| 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 D:\MySQL\share\charsets\
+--------------------------+--------------------------+
如果出现上述情况则需要更改数据库编码: 两种方法, 第一种是一次搞定, 第二种只对当前连接有效,断开连接,恢复更改前状态
方法1: alter database 数据库名 charset utf8;
方法2: set character_set_database = utf8;
再用命令: show variables like '%char%';
+--------------------------+--------------------------+
| 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 D:\MySQL\share\charsets\
+--------------------------+--------------------------+
此时编码已经一致, 但是,对数据库中的表进行插入中文字符操作, 仍然会报 : ERROR 1366 (HY000)
---> set character_set_client = gbk; 设置插入时接收的编码为GBK, 这样就可以插入中文了
此时中文字符已经可以插入, 但查询结果却还是乱码, 再更改一处即可:
---> set character_set_results = gbk; 设置输出结果的编码为GBK
注: 这样的设置只对当前连接有关, 连接断开, 这些设置恢复数据库默认设置状态,因此,如果需要,每次连接都得设置!
另外:ERROR 1366 (HY000)错误主要出现于控制台(cmd/黑窗口) 执行SQL语句插入中文时弹出,
用mysql-front 软件插入时不会报字符问题, java通过JDBC连接数据库执行executeUpdate("insert 语句") 中文也能成功插入数据且不会报错!
PHP解决乱码问题只需在连接后加入mysql_query("set names 'gbk'") 就OK!
如: $conn = mysql_connect("localhost","root","");
mysql_query("set names 'gbk'");
mysql insert中文乱码无法插入ERROR 1366 (HY000): Incorrect string value的更多相关文章
- 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创建表之后 ...
- 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 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%' ...
- MySQL ERROR 1366(HY000) Incorrect string value
有以下两张表: mysql> show tables; +---------------+ | Tables_in_old | +---------------+ | book | | pres ...
- Linux MySQl 5.7.17 MySQL ERROR 1366(HY000):Incorrect string value 解决方法
MySQL ERROR 1366(HY000):Incorrect string value,在往数据库中插入中文的时候会出现. 这也就是编码问题,网上大部分都是说设置下配置文件中的设置,而可悲的是在 ...
- ERROR 1366 (HY000): Incorrect string value:MySQL数据库、表的字符集为GBK
mysql> update userinfo set MEDIASOURCE = 'CS02-北京' where IMPORTNO = 'IMP201640613101206';ERROR 13 ...
- 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 数据库字符集问 ...
随机推荐
- SHDP--Working With HBase(一)之基本介绍
最近在做web项目使用到了Hadoop,HBase,在这里对Spring For Hadoop(SHDP)的使用做个总结,主要使用了SHDP中提供的一些封装好的HBase模块. Spring For ...
- 算法设计手冊(第2版)读书笔记, Springer - The Algorithm Design Manual, 2ed Steven S.Skiena 2008
The Algorithm Design Manual, 2ed 跳转至: 导航. 搜索 Springer - The Algorithm Design Manual, 2ed Steven S.Sk ...
- Java 线程第三版 第八章 Thread与Collection Class 读书笔记
JDK1.2引入最有争议性的改变是将集合类默觉得不是Thread安全性的. 一.Collection Class的概述 1. 具有Threadsafe 的Collection Class: j ...
- paip.c++ qt 图片处理 检测损坏的图片
paip.c++ qt 图片处理 检测损坏的图片 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net ...
- c保存lua函数
使用下面方式可保存lua任何值,目前只实现fucntion的保存,且无参数.如果需要实现参数,可自己扩展: 可实现下面方式: CFun( lua_fun ) -- okCFun( function() ...
- Android设置背景
一.设置图片背景 首先你先将一个的背景图片存入工程中res/drawble(当然drawble-hdpi.drawble-mdpi.drawble-ldpi中一个或者几个文件夹都可)文件夹中.假如我存 ...
- SQL Performance Improvement Techniques(转)
原文地址:http://www.codeproject.com/Tips/1023621/SQL-Performance-Improvement-Techniques This article pro ...
- Java开发23中设计模式
设计模式(Design Patterns) 设计模式是一套被反复使用,多数人知晓的,经过分类编目的,代码设计经验的总结.使用设计模式是为了可重用代码,让代码更容易被他人理解,保证代码的可靠性.毫无疑问 ...
- git基础命令
git pull 更新git status 查看文件状态git add .添加所有git commit -a -m "xxxx" 提交git push 推送至服务器git dif ...
- RemoteViews的理解和使用
一.RemoteViews简介 作用:跨进程更新界面 使用场景:通知栏.桌面小部件 二.在通知栏上的应用 原理:通过RemoteViews加载布局,通过 ...