MySQL 亂碼實戰解決ERROR 1366 (HY000): Incorrect string value: '
ERROR 1366 (HY000): Incorrect string value:
此種亂碼解決方案如下:
首先,設定自己資料庫的編碼統一:
Connection id: 81
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.0.67-community-nt MySQL Community Edition
(GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: gbk
Db characterset: gbk
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
隨後到自己的表裡面:
如我的這個表:content 表
+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| ad | smallint(6) | NO | | 0 | |
| title | char(30) | YES | | NULL | |
| author | varchar(30) | YES | | NULL | |
| content | text | YES | | NULL | |
+---------+-------------+------+-----+---------+----------------+
mysql> insert into content(title,author,content) values('插入成','修改於','文字元');
立刻報錯:
ERROR 1366 (HY000): Incorrect string value:
'\xD0\xDE\xB8\xC4\xD3\xDA' for colum
n 'author' at row 1
mysql> insert into content(title,author,content)
values('插入成','修改於','文字
符');
ERROR 1366 (HY000): Incorrect string value: '\xD0\xDE\xB8\xC4\xD3\xDA'
for colum
n 'author' at row 1
想招吧,哎:以下是解決方案:
mysql> alter table content modify author varchar(30) character set gbk;
對,就是這一句程式碼。很實用的,將表裡面的所有列都進行一次這樣的“洗禮”,大功告成!
----
不,還沒完,頁面需要宣告用GBK或者GB2312編碼,而且在頁面需要進行轉碼:
String content1 = new String(request.getParameter("content1").getBytes("ISO-8859-1"));
頁面讀取不需要轉碼,寫入需要轉碼
come from:http://www.blogjava.net/chenglu/archive/2009/04/17/MySQL-LuanMa.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-662841/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL ERROR 1366(HY000):Incorrect string value:''for column''at row 1解決方案MySqlError
- mysql 報錯:ERROR 1366 (HY000): Incorrect string value: ‘\xD5\xC5\xC8\xFD‘ for column ‘name‘ at row 1MySqlError
- mysql執行sql指令碼報錯ERROR 1366 (HY000) 解決MySql指令碼Error
- 【MySQL】Incorrect string value 問題一則MySql
- MYSQL寫入資料時報錯ERROR 1366 (HY000): Incorrect string value: '\xE8\x8B\xB1\xE5\xAF\xB8...' for c 插入中文不能插...MySqlError
- PHP連線SQL資料庫無法顯示emoji表情的解決辦法(變成問號、1366 Incorrect string value)PHPSQL資料庫
- java.sql.SQLException: Incorrect string valueJavaSQLException
- 【BUG記錄】MySQL插入Emoji表情報錯"Incorrect string value"MySql
- 【MySQL報錯】1366 - Incorrect string value: ‘\xE6\x80\xBB\xE7\xBB\x8F...‘ for column ‘name‘ at row 1MySql
- MySQL案例02:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGESMySqlError
- MySQL: Incorrect string value: '\xF0\xA4\xBD\x82'分析MySql
- MySQL解決中文亂碼MySql
- MySQL插入資料1366錯誤解決方案MySql
- MySql中文亂碼問題解決MySql
- 解決MySQL中文亂碼問題MySql
- MYSQL亂碼問題解決方法MySql
- ERROR 1290 (HY000) 解決辦法Error
- 解決:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\x94‘ for columnJavaSQLException
- ORACLE匯出文字到MYSQL 報錯 Incorrect integer value: ''OracleMySql
- 解決Mysql匯入亂碼問題MySql
- mysql 插入中文亂碼解決方案 轉MySql
- mysql與jsp亂碼解決方法MySqlJS
- 解決 Incorrect datetime value: '0000-00-00 00:00:00' 報錯
- MySQL錯誤Incorrect file format解決方案薦MySqlORM
- ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default valueError
- MySQL字符集亂碼與解決方案MySql
- navicat for mysql顯示中文亂碼解決方案MySql
- 讀mysql中文亂碼問題解決方法MySql
- java連線mysql中文亂碼解決之道JavaMySql
- Mybatis Data truncation: Truncated incorrect DOUBLE value: '*'MyBatis
- Error format not a string literal and no format arguments解決方案ErrorORM
- mysql命令列查詢亂碼怎麼解決?MySql命令列
- mysql使用source 命令亂碼問題解決方法MySql
- mysql 匯入中文亂碼解決一例MySql
- 解決JSP讀寫MYSQL亂碼問題JSMySql
- MYSQL ERROR 2003 (HY000) CanMySqlError
- ERROR 2002 (HY000): Cant connect to local MySQL server through socket的解決方法ErrorMySqlServer
- 解決ERROR 1030 (HY000): Got error 168 from storage engine apparmorErrorGoAPP