目录

工欲善其事

实践出真知

活跃标签: linux java mysql 待分类 js springboot win10 电路 vue macOS nginx esp32 windows git docker idea maven esp8266 python Arduino

存档:

X

mysql 基本命令语句

mysql 数据库安装后需要配置用户,数据库和表信息:

创建用户

create user 'root'@'%' identified by '123456';
grant all privileges on *.* to 'root'@'%';
flush privileges;

注意第一行的 % 要和第二行的% 一致

删除用户

drop user 'user'@'127.0.0.1';

创建数据库

create database [数据库名] default character set utf8mb4 collate utf8mb4_general_ci;

创建表

create table IF NOT EXISTS [表名]
(
    id       int auto_increment,
    username varchar(255) null comment '注释',
    password varchar(255) null,
    mobile   varchar(255),
    primary key (`id`) #主键
)
    ENGINE = InnoDB
    DEFAULT CHARSET = utf8mb4 comment '表注解';

创建字段

alter table [表名] add column [字段] varchar(255) not null comment '备注' after [字段];

修改字段

alter table [表名]
    modify [字段名] varchar(255) null comment '备注';
alter table [表名]
    change [原名 新名] varchar(255) null comment '备注';

标题:mysql 基本命令语句
作者:llilei
地址:http://solo.llilei.work/articles/2021/01/19/1611018540458.html