一、实验项目:
MySQL安全管理。
二、实验目的
掌握用户管理和权限控制的方法。
三、实验内容
1、创建petstore数据库管理用户a0001、店员用户s0001和顾客用户u0001,密码均为123456。
create user
a0001@localhost identified by '123456',
s0001@localhost identified by '123456',
u0001@localhost identified by '123456';
2、将用户a0001的密码改为admin123。
update mysql.user set password=PASSWORD('admin123') where user='a0001';
或者
update mysql.user set authentication_string=PASSWORD('admin123') where user='a0001';
3、授予用户u0001对petstore库中product表有select操作权限。
grant select on product to u0001@localhost;
Show grants for u0001@localhost;
4、授予用户u0001对petstore库中account表的姓名列和地址列有UPDATE权限。
grant update(fullname,address)on account to u0001@localhost;
Show grants for u0001@localhost;
5、授予用户a0001对所有库都有所有操作权限 。
grant all on *.* to a0001@localhost;
Show grants for a0001@localhost;
6、授予用户s0001对petstore库中所有表有select操作权限,并允许其将该权限授予其他用户。
grant select on petstore.* to s0001@localhost with grant option;
Show grants for s0001@localhost;
7、收回用户u0001对petstore库中account表上的UPDATE操作权限。
revoke update on petstore.account from u0001@localhost;
Show grants for u0001@localhost;