Mysql 5.7.18 利用 MySQL proxies_priv(類比角色)實作類別似使用者組管理

來源:互聯網
上載者:User

標籤:ase   html   grant   許可權   技術   data   log   str   ges   

利用 MySQL proxies_priv(類比角色)實作類別似使用者組管理

角色(Role)可以用來批量系統管理使用者,同一個角色下的使用者,擁有相同的許可權。 

MySQL5.7.X以後可以類比角色(Role)的功能,通過mysql.proxies_priv類比實現

本文參考自:http://www.innomysql.net

1、配置proxy

mysql> show variables like "%proxy%"; #查看當前proxy是否開啟,表示沒有開啟

mysql> set global check_proxy_users =on; #開啟proxy 表示已開啟

mysql> set global mysql_native_password_proxy_users = on;

mysql> exit

Bye #以上設定參數,對當前會話無效,需要退出後重新登入,或直接設定到my.cnf中去

2、建立使用者

mysql> create user will_dba; #類似組

mysql> create user ‘will‘;

mysql> create user ‘tom‘; #密碼就不設定了,如需設定密碼後面加上identified by ‘123‘

3、將will_dba的許可權映射(map)到will,tom

mysql> grant proxy on will_dba to will;

mysql> grant proxy on will_dba to tom;

4、給will_dba(類比的Role)賦予實際許可權

mysql> grant select on *.* to will_dba;

5、查看 will_dba 的許可權

mysql> show grants for will_dba;

6、查看will,和tom 的許可權

mysql> show grants for will;

mysql> show grants for tom;

7、查看 proxies_priv的許可權

mysql> mysql> select * from mysql.proxies_priv;

8、驗證

使用will和tom使用者查看資料庫

[[email protected] ~]# mysql -utom -p

mysql> show databases; #tom使用者我們之前沒有賦予許可權,但這裡可以查看

mysql> show tables;

mysql> select * from user\G

mysql.proxies_priv僅僅是對Role的類比,和Oracle的角色還是有所不同.官方稱呼為Role like

MySQL5.6.X 類比Role功能需要安裝外掛程式,具體方法請參考:

https://dev.mysql.com/doc/refman/5.6/en/proxy-users.html

https://dev.mysql.com/doc/refman/5.6/en/pluggable-authentication.html

 

Mysql 5.7.18 利用 MySQL proxies_priv(類比角色)實作類別似使用者組管理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.