Featured image of post MYSQL创建数据库设定字符集为utf8/utf8mb4

MYSQL创建数据库设定字符集为utf8/utf8mb4

MYSQL创建数据库设定字符集

1. 设定数据库字符集为utf8,名称为mydb1

create database mydb1 default character set utf8 collate utf8_general_ci;

2. 设定数据库字符集为utf8mb4,名称为mydb2(个人推荐选择utf8mb4_unicode_ci)

create database mydb2 default character set utf8mb4 collate utf8mb4_unicode_ci;

或者

create database mydb2 default character set utf8mb4 collate utf8mb4_general_ci;

修改用alter

3. 设定数据库字符集为gbk,名称为mydb2

create database mydb3 default character set gbk collate gbk_chinese_ci;

4. 更改数据库的字符编码

ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

5. 参考

http://t.csdnimg.cn/G1fTh

http://t.csdnimg.cn/LnliH

Licensed under CC BY-NC-SA 4.0