MySQL数据库utf8升级utf8mb4的步骤

MySQL数据库utf8升级utf8mb4的步骤

utf8升级utf8mb4具体步骤:首先将我们数据库默认字符集由utf8更改为utf8mb4,然后将表默认字符集也更改为utf8mb4,最后再把存储表情的字段默认字符集也做相应的调整。

SQL 语句

# 修改数据库

> ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;

# 修改表

> ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

# 修改表字段

> ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

修改MySQL配置文件,新增如下参数:

default-character-set = utf8mb4

default-character-set = utf8mb4

character-set-client-handshake = FALSE

character-set-server = utf8mb4

collation-server = utf8mb4_unicode_ci

init_connect='SET NAMES utf8mb4'
 

你可能感兴趣的:(数据库,mysql,sql)