1. 程式人生 > >MYSQL插入中文的錯誤:Incorrect string value: '\xE7\xA8\x8B\xE5\xBA\x8F...' for column 'description' at row 1

MYSQL插入中文的錯誤:Incorrect string value: '\xE7\xA8\x8B\xE5\xBA\x8F...' for column 'description' at row 1

1>進入mysql:mysql -u root -p

2>輸入mysql 密碼

3>顯示資料庫:show databases;

4>選擇資料庫:use Learn(我要修改的表banner位於Learn資料庫下)

5>顯示錶的詳細資訊:show create table banner;

將表banner的編碼轉換成utf8mb4

alter table TABLE_NAME convert to character set utf8mb4 collate utf8mb4_bin; (將TABLE_NAME替換成你的表名),指令截圖如下:

修改後再次顯示錶banner的詳細資訊:show create table banner;

可以看到列的編碼從latin1變成了utf8mb4_bin,表的編碼從utf8變成了utf8mb4.

MYSQL基本指令請戳下面連結:

https://blog.csdn.net/ithomer/article/details/5131863