1、改ini文件
在mysql的安装目录下找到my.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'
2、改变数据库字符
alter database 数字库名 character set = utf8mb4 collate=utf8mb4_unicode_ci;
3、改变表字符
alter table 数字表名 convert to character set utf8mb4 collate utf8mb4_bin;
4、查看更新后的编码:
show variables like 'character_set_database';