mysql 報錯: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
資料庫字符集問題,檢視資料庫狀態:
mysql> status;
mysql Ver 14.14 Distrib 5.6.12, for Win32 (x86)
Connection id: 25
Current database: information_schema
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.12 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
Uptime: 8 hours 54 min 47 sec
Threads: 1 Questions: 372 Slow queries: 0 Opens: 108 Flush tables: 1 Open t
ables: 62 Queries per second avg: 0.011
我要使用的庫test的字符集是latin1,該字符集不支援中文字元。
檢視錶引擎狀態:
mysql> show create table ttt;
±------±----------------------------------------------------------------------
-----------------------------------------------------------------------+
| Table | Create Table
|
±------±----------------------------------------------------------------------
-----------------------------------------------------------------------+
| ttt | CREATE TABLE ttt
(
id
int(11) NOT NULL,
name
varchar(20) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
±------±----------------------------------------------------------------------
-----------------------------------------------------------------------+
修改表字符集:
mysql> alter table ttt character set utf8;
Query OK, 0 rows affected (0.10 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table ttt;
±------±----------------------------------------------------------------------
----------+
| Table | Create Table
|
±------±----------------------------------------------------------------------
----------+
| ttt | CREATE TABLE ttt
(
id
int(11) NOT NULL,
name
varchar(20) CHARACTER SET latin1 DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
±------±----------------------------------------------------------------------
----------+
修改欄位字符集:
mysql> alter table ttt modify name varchar(20) character set utf8;
Query OK, 0 rows affected (1.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show create table ttt;
±------±----------------------------------------------------------------------
---------------------------------------------------------------------+
| Table | Create Table
|
±------±----------------------------------------------------------------------
---------------------------------------------------------------------+
| ttt | CREATE TABLE ttt
(
id
int(11) NOT NULL,
name
varchar(20) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
±------±----------------------------------------------------------------------
---------------------------------------------------------------------+
1 row in set (0.02 sec)
OK!
相關文章
- 【MySQL報錯】1366 - Incorrect string value: ‘\xE6\x80\xBB\xE7\xBB\x8F...‘ for column ‘name‘ at row 1MySql
- 【BUG記錄】MySQL插入Emoji表情報錯"Incorrect string value"MySql
- pymysql.err.OperationalError: (1136, “Column count doesn‘t match value count at row 1“)報錯反省。MySqlError
- MySQL 5.7 建立使用者報錯 ERROR 1805 (HY000): Column count of mysql.user is wrongMySqlError
- java.sql.SQLException: Incorrect string valueJavaSQLException
- MySQL案例02:ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGESMySqlError
- MySQL報錯ERROR 2013 (HY000): Lost connection to MySQL server during queryMySqlErrorServer
- MySQL 報錯 ERROR 1290 (HY000): running with the --secure-file-privMySqlError
- 【MySQL】ERROR 1290 (HY000): --secure-file-priv--匯出報錯MySqlError
- Mysql連線錯誤ERROR 2003 (HY000)MySqlError
- MySQL: Incorrect string value: '\xF0\xA4\xBD\x82'分析MySql
- 錯誤:duplicate column name: picstitle
- mysql 5.6.25報錯ERROR 1372 (HY000): Password hash 的一點思考MySqlError
- Convert DataFrame string complex i to j python // “Cloning” row or column vectorsPython
- Centos7-mysql執行報錯ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.CentOSMySqlError
- 查LOB文字內容報錯ORA-06502: numeric or value error: character string buffer..Error
- 解決:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\x94‘ for columnJavaSQLException
- PHP連線SQL資料庫無法顯示emoji表情的解決辦法(變成問號、1366 Incorrect string value)PHPSQL資料庫
- MySQL建立使用者報錯 ERROR 1396 (HY000): Operation CREATE USER failed for 'afei'@'%'MySqlErrorAI
- 解決 Incorrect datetime value: '0000-00-00 00:00:00' 報錯
- mysql 8 報錯 ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repositoryMySqlErrorAIStruct
- ERROR 1290 (HY000): The MySQL server is running withErrorMySqlServer
- 阿里雲mysql遠端登入報ERROR 2027(HY000)阿里MySqlError
- ORA-12899: value too large for column ORG_NAME (actual: 145, maximum: 128)
- linux下連線mysql報錯ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysqLinuxMySqlErrorServer
- MySQL5.7叢集(MGR)啟動報ERROR 3092 (HY000)MySqlError
- 小程式 · 報錯:Error: errCode: -501007 ,errMsg: Invalid Key Name (__keyPath)Error
- Flutter 之 Row、Column詳解Flutter
- 關於報錯Error creating bean with name 'xxxxx': Invocation of init method....ErrorBean
- Flutter之Row/Column用法詳解Flutter
- Flutter基礎元件Row&ColumnFlutter元件
- 【MySQL】ERROR 1878 (HY000): Temporary file write failure.MySqlErrorAI
- mysql錯誤詳解(1819):ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsMySqlErrorUIREM
- JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from StringJSONErrorJavaLDA
- ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization paErrorMySqlServer
- [20231103]sqlplus column new_value old_value.txtSQL
- [20230303]sqlplus column new_value old_value.txtSQL
- Flutter 佈局(七)- Row、Column詳解Flutter