node.js Incorrect string value: 'xF0x9Fx92x9ExE5x9B...' for column 'nickname' at row 1

xiaoxiao2021-02-28  95

大概原因是插入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

最新回复(0)