当前位置:网站首页>MySQL之账号管理、建库以及四大引擎+案例
MySQL之账号管理、建库以及四大引擎+案例
2022-06-27 00:09:00 【ˡᵒᵛᵉ一杯美式】
1、查找数据库引擎
show engines;
2、创建数据库
#create database 数据库名
create database text;
#完整写法
create database if not exists text default charset utf8 collate utf8_general_ci;
3、查找数据库
show databases;
5、账号管理
#5.1、创建用户并设置密码
create user zking identified by '123456';
#5.2、切换用户
use mysql;
#5.3、查看用户信息
#192.168.1.% ipv4 ipv6
select * from user;
select host,user,authentication_String from user;
4、删除数据库(神用户,建议禁用;)
drop user zking;
6修改密码
set password for zking=password('1234');
7刷新配置
flush privileges;
8授权(grant)
#语法:grant all [pricilenges] on databasename.tablename to 用户名@'%'
#garnt all on *.* to [email protected]'%';
grant select,delete on t277.t_book to z[email protected]'%';
9撤权(revoke)
#语法:revoke all [privileges] on dataasename.tablename from 用户名@'%';
#revoke all on *.* from [email protected]'%';
revoke select on t277.t_book from [email protected]'%';
10查询权限
show grants for zking;
下面就是一个案例
#decimal(5,2)
#总共五位,整数位三位,小鼠位两位小数
create table if not exists t_money(
id int not null primary key auto_increment,
money decimal(5,2)
);
select * from t_money;
create table t_student(
sid int not null primary key auto_increment comment '学生编号',
sname varchar(20) not null comment '学生姓名',
idcard varchar(18) not null comment '身份证号',
sex char(1) default '1' comment '学生性别,1=男,0=女',
createdate timestamp default current_timestamp comment '创建日期',
unique(sname,idcard)
)comment '学生信息表';
create table t_score(
sid int not null comment '学生编号',
cid int not null comment '课程编号',
score float default 0 comment '成绩',
foreign key(sid) references t_student(sid)
)comment '学生成绩表';
#先删外表,再删主表
insert into t_score(sid,cid,score) values(1,2,90.5);
select * from t_student;
select * from t_score;以上就是今天的分享!
边栏推荐
- 从位图到布隆过滤器,C#实现
- 2022年地理信息系统与遥感专业就业前景与升学高校排名选择
- Lwip之定时机制
- 论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》
- 技术干货|极速、极智、极简的昇思MindSpore Lite:助力华为Watch更加智能
- 小白看MySQL--windows环境安装MySQL
- Amway! How to provide high-quality issue? That's what Xueba wrote!
- test
- 串口调试工具 mobaxterm 下载
- Is it reliable to speculate in stocks by mobile phone? Is it safe to open an account and speculate in stocks online
猜你喜欢

The fourth bullet of redis interview eight part essay (end)

大赛报名 | AI+科学计算重点赛事之一——中国开源科学软件创意大赛,角逐十万奖金!

redis详细教程

kubeadm创建kubernetes集群

敲重点!最全大模型训练合集!

技术干货|什么是大模型?超大模型?Foundation Model?

Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022

MindSpore新型轻量级神经网络GhostNet,在ImageNet分类、图像识别和目标检测等多个应用场景效果优异!

冲刺强基计划数学物理专题二

com.fasterxml.jackson.databind.exc.MismatchedInputException: Expected array or string. at [Source:x
随机推荐
How do new investors open accounts online? Is it safe to open accounts online and speculate in stocks
墨者学院-SQL注入漏洞测试(报错盲注)
气液滑环与其他滑环的工作原理有什么区别
Using physical information neural network to solve hydrodynamics equations
剑指 Offer 10- II. 青蛙跳台阶问题
手机能开户炒股吗 网上开户炒股安全吗
Network in network (dolls)
【UVM实战 ===> Episode_3 】~ Assertion、Sequence、Property
安利!如何提优质的ISSUE?学霸是这样写的!
记录一次换行符引起的bug
手机炒股靠谱吗 网上开户炒股安全吗
kubernetes可视化界面dashboard
Concepts de base de données Oracle
Intrusion trace cleaning
How to control the quality of HD slip ring in the production process
These 10 copywriting artifacts help you speed up the code. Are you still worried that you can't write a copywriting for US media?
滑环安装有哪些技巧和方法
Live review | Ziya &ccf TF: Discussion on software supply chain risk management technology under cloud native scenario
當Transformer遇見偏微分方程求解
Serial port debugging tool mobaxtermdownload