修改配置文件my.cnf,需要重启Mysql服务后生效
[mysqld]
character-set-server=utf8mb4
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
修改数据库或表的字符集
ALTER DATABASE 数据库 CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE 表名 CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;