MySQL權限篇之CREATE USER

權限CREATE USER是global privilege。

該權限可以創建,修改和刪除用戶。

如:

mysql> show grants for 'ut01'@'%';
+----------------------------------------+
| Grants for ut01@%                      |
+----------------------------------------+
| GRANT CREATE USER ON *.* TO 'ut01'@'%' |  #global privilege只能on *.*,否則報語法錯誤
+----------------------------------------+
1 row in set (0.00 sec)


mysql>


mysql> select user();
+----------------+
| user()         |
+----------------+
| ut01@localhost |
+----------------+
1 row in set (0.00 sec)


mysql> create user 'ut02'@'%';
Query OK, 0 rows affected (0.07 sec)


mysql> alter user 'ut02'@'%' identified by '20127163';
Query OK, 0 rows affected (0.05 sec)


mysql> alter user 'ut02'@'%' PASSWORD EXPIRE;
Query OK, 0 rows affected (0.12 sec)


mysql> alter user 'ut02'@'%' account lock;
Query OK, 0 rows affected (0.03 sec)


mysql> drop user 'ut02'@'%';
Query OK, 0 rows affected (0.03 sec)


mysql> drop user 'ut03'@'%';  #該用戶爲另外一個super用戶所創建,但其同樣能夠刪除
Query OK, 0 rows affected (0.04 sec)


mysql>


ps,mysql裏面的schema和oracle的schema含義還是有很大區別的。

oracle的schema是用戶和該用戶的所有對象的集合。

而mysql的schema僅僅是一個庫,和用戶沒有關係。

也就是說,mysql的schema裏的對象(如表,視圖,函數,用戶等)和用戶沒有關係。

比如,ut01@%創建了表t1,但是t1表不屬於ut@%用戶,其只屬於某個schema。

它不像oralce裏面那樣,對象必須依賴某個用戶。

mysql沒有這層概念。

這樣就導致了,用戶對某個對象的權限具有相當大的靈活性。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章