国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL的Grant命令詳解

2024-07-24 12:47:54
字體:
來源:轉載
供稿:網友

本文實例,運行于 MySQL 5.0 及以上版本。

MySQL 賦予用戶權限命令的簡單格式可概括為:

grant 權限 on 數據庫對象 to 用戶 

一、grant 普通數據用戶,查詢、插入、更新、刪除 數據庫中所有表數據的權利。

復制代碼 代碼如下:

grant select on testdb.* to common_user@'%'
grant insert on testdb.* to common_user@'%'
grant update on testdb.* to common_user@'%'
grant delete on testdb.* to common_user@'%'

或者,用一條 MySQL 命令來替代:

復制代碼 代碼如下:

grant select, insert, update, delete on testdb.* to common_user@'%'

二、grant 數據庫開發人員,創建表、索引、視圖、存儲過程、函數。。。等權限。

grant 創建、修改、刪除 MySQL 數據表結構權限。

復制代碼 代碼如下:

grant create on testdb.* to developer@'192.168.0.%';
grant alter  on testdb.* to developer@'192.168.0.%';
grant drop   on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 外鍵權限。

復制代碼 代碼如下:
grant references on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 臨時表權限。

復制代碼 代碼如下:

grant create temporary tables on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 索引權限。

grant index on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 視圖、查看視圖源代碼 權限。

復制代碼 代碼如下:

grant create view on testdb.* to developer@'192.168.0.%';
grant show   view on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 存儲過程、函數 權限。

復制代碼 代碼如下:

grant create routine on testdb.* to developer@'192.168.0.%'; -- now, can show procedure status
grant alter  routine on testdb.* to developer@'192.168.0.%'; -- now, you can drop a procedure
grant execute        on testdb.* to developer@'192.168.0.%';

三、grant 普通 DBA 管理某個 MySQL 數據庫的權限。

復制代碼 代碼如下:

grant all privileges on testdb to dba@'localhost'

其中,關鍵字 “privileges” 可以省略。

四、grant 高級 DBA 管理 MySQL 中所有數據庫的權限。

復制代碼 代碼如下:

grant all on *.* to dba@'localhost'

五、MySQL grant 權限,分別可以作用在多個層次上。

1. grant 作用在整個 MySQL 服務器上:

復制代碼 代碼如下:

grant select on *.* to dba@localhost; -- dba 可以查詢 MySQL 中所有數據庫中的表。
grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有數據庫
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彰武县| 灵台县| 澄迈县| 天峨县| 郁南县| 辽源市| 保山市| 城固县| 普兰店市| 渝中区| 监利县| 新营市| 湘潭县| 衡东县| 潍坊市| 天等县| 肇源县| 宝坻区| 德令哈市| 井研县| 新田县| 双牌县| 高雄县| 龙山县| 定襄县| 招远市| 甘德县| 山阴县| 尉氏县| 延安市| 务川| 乌拉特前旗| 兖州市| 北京市| 北辰区| 边坝县| 定远县| 达尔| 伊春市| 将乐县| 商丘市|