【MySQL報錯】1366 - Incorrect string value: ‘\xE6\x80\xBB\xE7\xBB\x8F...‘ for column ‘name‘ at row 1
某天插入資料時出現報錯
出現這個錯誤的原因是,資料庫的編碼格式為latin1 而我要將utf8的中文插入到資料庫中。
解決辦法:
找到表中欄位
改變欄位的字元編碼
總結:
MySQL中預設字符集的設定有四級:伺服器級,資料庫級,表級 。最終是欄位級 的字符集設定。注意前三種均為預設設定,並不程式碼你的欄位最終會使用這個字符集設定。請將你的插入資料字元編碼和表中欄位編碼統一。
相關的sql命令
修改資料庫字符集:
ALTER DATABASE db_name DEFAULT CHARACTER SET character_name [COLLATE ...];
把表預設的字符集和所有字元列(CHAR,VARCHAR,TEXT)改為新的字符集:
ALTER TABLE tbl_name CONVERT TO CHARACTER SET character_name [COLLATE ...]
如:ALTER TABLE logtest CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
只是修改表的預設字符集:
ALTER TABLE tbl_name DEFAULT CHARACTER SET character_name [COLLATE...];
如:ALTER TABLE logtest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
修改欄位的字符集:
ALTER TABLE tbl_name CHANGE c_name c_name CHARACTER SET character_name [COLLATE ...];
如:ALTER TABLE logtest CHANGE title title VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
檢視資料庫編碼:
SHOW CREATE DATABASE db_name;
檢視錶編碼:
SHOW CREATE TABLE tbl_name;
檢視欄位編碼:
SHOW FULL COLUMNS FROM tbl_name;
Linux 系統下解決辦法:
參考
https://www.cnblogs.com/afeiiii/p/13220997.html
相關文章
- mysql 報錯:ERROR 1366 (HY000): Incorrect string value: ‘\xD5\xC5\xC8\xFD‘ for column ‘name‘ at row 1MySqlError
- 【BUG記錄】MySQL插入Emoji表情報錯"Incorrect string value"MySql
- pymysql.err.OperationalError: (1136, “Column count doesn‘t match value count at row 1“)報錯反省。MySqlError
- java.sql.SQLException: Incorrect string valueJavaSQLException
- MySQL: Incorrect string value: '\xF0\xA4\xBD\x82'分析MySql
- 錯誤:duplicate column name: picstitle
- Convert DataFrame string complex i to j python // “Cloning” row or column vectorsPython
- 解決:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\x94‘ for columnJavaSQLException
- PHP連線SQL資料庫無法顯示emoji表情的解決辦法(變成問號、1366 Incorrect string value)PHPSQL資料庫
- 解決 Incorrect datetime value: '0000-00-00 00:00:00' 報錯
- ORA-12899: value too large for column ORG_NAME (actual: 145, maximum: 128)
- Flutter 之 Row、Column詳解Flutter
- Flutter之Row/Column用法詳解Flutter
- Flutter基礎元件Row&ColumnFlutter元件
- [20231103]sqlplus column new_value old_value.txtSQL
- [20230303]sqlplus column new_value old_value.txtSQL
- Flutter 佈局(七)- Row、Column詳解Flutter
- Flutter線性佈局Row和ColumnFlutter
- Flutter控制元件--Row、Column和StackFlutter控制元件
- 升級提示 執行SQL發生錯誤!錯誤:duplicate column name: picstitleSQL
- SpringBoot升級到3.2.0報錯Invalid value type for attribute ‘factoryBeanObjectType‘: java.lang.StringSpring BootBeanObjectJava
- WPF Livecharts C# Column name changeEchartsC#
- pbootcms升級提示 執行SQL發生錯誤!錯誤:duplicate column name: picstitlebootSQL
- 鴻蒙HarmonyOS實戰-ArkUI元件(Row/Column)鴻蒙UI元件
- Flutter 佈局控制元件篇-->Row、ColumnFlutter控制元件
- Flutter Spacer 靈活配置你的Row/ColumnFlutter
- vue報錯:[Vue warn]: Invalid prop: type check failed for prop "value". Expected Number, got String....VueAIGo
- 查LOB文字內容報錯ORA-06502: numeric or value error: character string buffer..Error
- Java更新資料庫報錯:Data truncation: Cannot create a JSON value from a string with CHARACTER SETJava資料庫JSON
- 515-Find Largest Value in Each Tree Row
- Unknown column ‘name‘ in ‘field list‘ ; bad SQL grammar []; nested exception is com.mysql.jdbc.excepExceptionMySqlJDBC
- beego報錯 table name: `xxx` not existsGo
- 記一次 打包報錯:Keystore was tampered with, or password was incorrect
- MySQL 5.7 建立使用者報錯 ERROR 1805 (HY000): Column count of mysql.user is wrongMySqlError
- MySQL, Incorrect usage of UNION and ORDER BYMySql
- element-ui中row-class-name的用法UI
- Qt 報錯 “類名”does not name a typeQT
- Mysql 報Row size too large 65535解決方法MySql