-- 修改默认字符集,注意此语句不会修改列的属性 mysql>alter table <表名> character set utf8 collate utf8_bin;
-- 修改表和列的属性 mysql>alter table 表名 CONVERT to character set utf8 collate utf8_bin;
7.修改字段编码格式
1 2 3
mysql>alter table <表名> change <字段名> <字段名> <类型> character set utf8; -- 示例 mysql>alter table user change username username varchar(20) character set utf8 not null;
SELECT CONCAT( 'ALTER TABLE ', TABLE_NAME, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;' ) FROM information_schema.`TABLES` WHERE TABLE_SCHEMA = 'DATABASE_NAME';