utf8 编码被广泛使用,能应对大多数场景;utf8mb4 是 utf8 的超集
数据库备份
mysqldump -uroot --databases <DB_NAME> > <DB_NAME>_backup.sql
查看数据库编码
use <DB_NAME>;
show variables like '%char%';
查看表及字段编码
show create table <TABLE_NAME>;
show full columns from <TABLE_NAME>;
调整数据库编码
alter database <DB_NAME> character set utf8mb4;
调整表及字段编码
alter table <TABLE_NAME> character set utf8mb4;
alter table <TABLE_NAME> modify column <COLUMN_NAME> <COLUMN_TYPE> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;