mysql权限管理

用户的创建

create user "yanzhao1"@"localhost" identified by "2019210902";

create user "yanzhao2"@"localhost" identified by "2019210902";

create user "yanzhao3"@"localhost" identified by "2019210902";

create user "yanzhao4"@"localhost" identified by "2019210902";
grant select,insert,update on *.* to "yanzhao4"@"localhost";

用户授权

  • 授予第一个用户为数据库级用户,对 dreamhom 拥有所有权
grant all on dreamhom.* to “yanzhao1”@”localhost”;
  • 授予第二个用户为表级用户,对dreamhom中的staff 表具有select,insert,delete 权限
grant select,insert,delete on dreamhom.staff to “yanzhao2”@”localhost”;
  • 授予第三个用户为列级用户,对 dreamhom 中的 staff 表的 fname列以及 lname 拥有 select 权限
grant select(fname,lname) on dreamhom.staff to “yanzhao3”@”localhost”;

权限回收

revoke select on *.* from "yanzhao4"@"localhost";

删除用户

drop user "yanzhao4"@"localhost";
上一篇:mysql-210715-03---DBA命令


下一篇:MySQL中GRANT和IDENTIFIED同时使用时出现near 'IDENTIFIED BY...” at line 1错误