MySQL安全管理-实验

一、实验目的

掌握用户管理和权限控制的方法。

二、实验内容

使用SQL语句完成下列题目:

1、创建petstore数据库管理用户a0001、店员用户s0001和顾客用户u0001,密码均为123456。(1分)

2、将用户a0001的密码改为admin123。(1分)

3、授予用户u0001对petstore库中product表有select操作权限。(0.5分)

4、授予用户u0001对petstore库中account表的姓名列和地址列有UPDATE权限。(0.5分)

5、授予用户a0001对所有库都 有所有操作权限 。(0.5分)

6、授予用户s0001对petstore库中所有表有select操作权限,并允许其将该权限授予其他用户。(1分)

7、收回用户u0001对petstore库中account表上的UPDATE操作权限。(0.5分)

实验代码及注释

1.
 select user from mysql.user;
create user
'a0001'@'localhost' identified by '123456',
's0001'@'localhost' identified by '123456',
'u0001'@'localhost' identified by '123456';
select user from mysql.user;
2.
 Select user,authentication_string from mysql.user where user='a0001';
set password for 'a0001'@localhost =password('admin123');
Select user,authentication_string from mysql.user where user='a0001';
3. 
Show grants for u0001@localhost;
grant select on petstore.product to u0001@localhost;
Show grants for u0001@localhost;
4. 
Show grants for u0001@localhost;
grant update(fullname,address) on petstore.account to u0001@localhost;
Show grants for u0001@localhost;
5. 
Show grants for a0001@localhost;
grant  all on *.* to a0001@localhost;
Show grants for a0001@localhost;
6. 
Show grants for s0001@localhost;
grant select on petstore.* to s0001@localhost  with grant option;
Show grants for s0001@localhost;
7.
Show grants for s0001@localhost;
revoke update on petstore.account from u0001@localhost;
Show grants for s0001@localhost;

运行结果截图

  • 10
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

moon-Joe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值