创建UTF-8的Mysql数据库

一、创建数据库

1. 创建UTF8编码数据库

CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

image

2. 验证数据库编码

show variables like 'char%'

image

CREATE DATABASE 的语法:

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_specification [, create_specification] ...]
create_specification:
[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name

二、修改数据库编码

ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

二〇一八年一月二十一日 20:29:23

点赞