進擊のpython
數據庫——權限管理
這沒有講解,只有要背的指令,和你自己的實操
授權表
user #該表放行的權限,針對:所有數據,所有庫下所有表,以及表下的所有字段
db #該表放行的權限,針對:某一數據庫,該數據庫下的所有表,以及表下的所有字段
tables_priv #該表放行的權限。針對:某一張表,以及該表下的所有字段
columns_priv #該表放行的權限,針對:某一個字段
創建用戶
create user 'egon'@'1.1.1.1' identified by '123';
create user 'egon'@'192.168.1.%' identified by '123';
create user 'egon'@'%' identified by '123';
授權:對文件夾,對文件,對文件某一字段的權限
查看幫助:help grant
常用權限有:select,update,alter,delete
all可以代表除了grant之外的所有權限
針對所有庫的授權:.
grant select on . to 'egon1'@'localhost' identified by '123'; #只在user表中可以查到egon1用戶的select權限被設置為Y
針對某一數據庫:db1.*
grant select on db1.* to 'egon2'@'%' identified by '123'; #只在db表中可以查到egon2用戶的select權限被設置為Y
針對某一個表:db1.t1
grant select on db1.t1 to 'egon3'@'%' identified by '123'; #只在tables_priv表中可以查到egon3用戶的select權限
針對某一個字段:
mysql> select * from t3;
+------+-------+------+
| id | name | age |
+------+-------+------+
| 1 | egon1 | 18 |
| 2 | egon2 | 19 |
| 3 | egon3 | 29 |
+------+-------+------+
grant select (id,name),update (age) on db1.t3 to 'egon4'@'localhost' identified by '123';
可以在tables_priv和columns_priv中看到相應的權限
刪除權限
revoke select on db1.* from 'egon'@'%';