weihomechen / blog-node

一个博客全栈应用的node服务端,前端部分传送门 https://github.com/weihomechen/blog
13 stars 2 forks source link

关于mysql支持emoji表情 #1

Open weihomechen opened 6 years ago

weihomechen commented 6 years ago

如果执行完sql文件发现插入emoji表情报错,需要设置字符集为utf8mb4

1、 先停止MySQLServer服务

service mysql stop

2、修改 my.cnf或者mysql.ini

[client]
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

3、然后重启 service mysql restart

4、进入mysql,查看相关字符集:SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';