通过官⽅⽹站提供的下载链接下载“MySQL社区版服务器”安装程序,如下图所示,建议下载离线安装版的MySQL Installer。



继续next,到如下




新版本还存在以下的选择




windows安装结束

安装后启动需要输入以下命令启动

help或?
help date types
show databases;

alter user 'root'@'localhost' identified by '你设置的密码';
alter database hrs default charset utf8mb4;
create database hrs default charset utf8mb4;
Query OK, 1 row affected (0.02 sec)
use hrs;
show tables;
create table `tb_dept_1`
(
`dno` integer not null comment '编号',
`dename` char(20) not null comment '名称',
`dlocation` varchar(20) not null comment '所在地',
primary key(dno)
)engine=innodb comment '部门表';

drop table tb_dept_1 if exists tb_dept_1;
alter table tb_dept add column dest date comment '成立日期';

alter table tb_dept drop column dest;

alter table tb_dept modify column dlocation varchar(50) not null;
修改列名字dlocation太长,修改为dlo
alter table tb_dept change column dlocation dlo varchar(200) not null comment '所在地';

alter table tb_dept add constraint uk_dept_dname unique (dename);

alter table tb_dept drop constraint uk_dept_dname;
检查约束,检测dloc字符长度>2
alter table tb_dept add constraint ck_dept_dloc check (char_length(dlo) >= 2);
删除约束
alter table tb_dept drop constraint ck_dept_dloc;
alter table tb_dept rename to tb_dept_change;
insert into tb_dept (dno,dename,dlo) values (01,'财务部','北京')
添加多行
insert into tb_dept (dno,dename,dlo) values
(02,'研发部','北京'),
(03,'财务部','北京'),
(04,'销售部','上海'),
(05,'财务部','广州');
select * from tb_dept;

delete from tb_dept where dno='2'

update tb_dept set dename = '销售3部',dlo = '武汉' where dno = 3;
