mysql資料插入失敗,檢視和修改字符集解決問題

2021-10-21 08:36:05 字數 762 閱讀 2311

背景

問題分析解決

檢視資料庫字符集

修改資料庫字符集

檢視資料庫的表字符集

修改資料庫的表字符集

檢視資料庫表的列字符集

當執行資料庫指令碼時出現如下問題,無法插入資料。 

[hy000][1366] incorrect string value: '\xe8\x8b\xa5\xe4\xbe\x9d...' for column 'dept_name' at row 1

新建資料庫時未考慮字符集,不同環境下新建資料庫預設字符集可能是不一樣的,這時出現問題需要檢視和修改字符集

-- 檢視資料庫資訊,包含字符集

select * from information_schema.schemata s where schema_name = '資料庫名稱';

-- 修改資料庫字符集為utf8

alter database ryvue character set utf8;

-- 檢視表資訊,包含字符集

show table status from 資料庫名稱;

-- 修改表的字符集

alter table 表名稱 convert to character set utf8;

-- 檢視表中所有列的字符集

show full columns from 表名稱;

MySQL資料庫插入中文失敗問題

問題描述 建立資料庫test字符集為utf8,表user字符集為utf8。插入中文字元時出現如下錯誤 error 1366 hy000 incorrect string value xce xe2 xd9 xbb for column user name at row 1 解決方法 方法一 在mys...

檢視mysql實時查詢和插入速度

有時候需要檢視資料庫的一些實時資料資訊,比如說每秒查詢或者插入的記錄,這時候就需要用到mysqladmin。使用extended status功能可以檢視實時的資料庫狀態。這裡檢視的都是歷史統計資料,如果配合r和i引數就可以檢視更新資料,r是列出本次和上次的資料差,i是重新整理時間 比如說 mysq...

hiernate 插入中文資料失敗

今天用別人的電腦建了個 hibernate 的小demo 出了點狀況。插入中文資料失敗,具體資訊如下 hibernate select max id from pe ck hibernate insert into pe ck username,password,age,id values 六月 0...