1. 程式人生 > 其它 >mysql grant授權

mysql grant授權

  1. 格式
grant 許可權 on 資料庫物件 to 使用者
  1. 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@'%'

grant select, insert, update, delete on testdb.* to common_user@'%'
  1. 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.%';
  1. grant 普通 DBA 管理某個 MySQL 資料庫的許可權。
grant all privileges on testdb to dba@'localhost'
  1. grant 高階 DBA 管理 MySQL 中所有資料庫的許可權。
grant all on *.* to dba@'localhost'
  1. 檢視當前使用者(自己)許可權:
show grants;
  1. 檢視其他 MySQL 使用者許可權:
show grants for dba@localhost;