MySQL必备技能之设置编码(九)

1、问题提出

在表中插入中文时,显示乱码。

2、问题解决

创建数据库并指定编码格式:

CREATE DATABASE world_test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE world_test;

创建表格:

CREATE TABLE world_1(
city_id int not null auto_increment,
city_name char(50) not null,
date datetime not null,
city_price int not null
);

添加数据:

INSERT INTO world_1(
1,
'美国',
'2020-03-10',
12
);

查看数据:

SELECT * FROM world_1;

返回数据:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章