不一样的身份, 能够干不一样的事情mysql
新增长的用户, 权限不多sql
咱们先新建用户dog数据库
CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
复制代码
没有权限时, 直接查询会报错安全
> 1142 - SELECT command denied to user 'dog'@'localhost' for table 'reader'
> 时间: 0s
复制代码
赋予权限post
use library;
grant select,DELETE on reader to dog@localhost;
复制代码
可是insert操做依然报错, 由于没有权限this
INSERT INTO `library`.`reader`
( `readerid`, `readername`, `readerpass`, `retypeid`, `readerdate`, `readerstatus` )
VALUES
( '0017', '苏小东', '123456', 1, '1999-09-09 00:00:00', '有效' );
复制代码
> 1142 - INSERT command denied to user 'dog'@'localhost' for table 'reader'
> 时间: 0s
复制代码
grant update(readername,readerpass) on library.reader to dog@localhost;
复制代码
grant select on library.* to dog@localhost;
复制代码
grant all on library.* to dog@localhost;
复制代码
grant insert, delete, update, select on *.* to dog@localhost;
复制代码
mysql> CREATE USER 'cat'@'localhost' IDENTIFIED BY '123456';
1227 - Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
mysql>
复制代码
一开始, dog用户是没有建立用户的权限的spa
grant create user on *.* to dog@localhost;
复制代码
以后, 能够成功3d
mysql> CREATE USER 'cat'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql>
复制代码
revoke select on library.reader from dog@localhost;
复制代码
我不喜欢被人收回权限, 因此就不演示了...code