大概原因是插入emoji表情占用四个字节照成的
解决:第一步:alter table anchor convert to character set utf8mb4 collate utf8mb4_bin;修改表的编码为utf8mb4 ,nickname也改一下吧,
第二步:链接的时候添加配置如下
collate charset
const connection = mysql.
createConnection({
host :
'localhost',
user :
'root',
password :
'xxx',
database :
'xxx',
charset:
"utf8mb4",
collate:
"utf8mb4_unicode_ci",
port:
'3306'
})
;
转载请注明原文地址: https://www.6miu.com/read-38363.html