mysql許可權管理

來源:互聯網
上載者:User

標籤:分享圖片   local   ima   tab   info   .com   針對   use   let   

#授權表user #該表允許存取的許可權,針對:所有資料,所有庫下所有表,以及表下的所有欄位db #該表允許存取的許可權,針對:某一資料庫,該資料庫下的所有表,以及表下的所有欄位tables_priv #該表允許存取的許可權。針對:某一張表,以及該表下的所有欄位columns_priv #該表允許存取的許可權,針對:某一個欄位#按圖解釋:user:允許存取db1,db2及其包含的所有db:允許存取db1,及其db1包含的所有tables_priv:允許存取db1.table1,及其該表包含的所有columns_prive:允許存取db1.table1.column1,只允許存取該欄位

  

 

舉例

#建立使用者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,deleteall可以代表除了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.t1grant select on db1.t1 to ‘egon3‘@‘%‘ identified by ‘123‘;  #只在tables_priv表中可以查到egon3使用者的select許可權#針對某一個欄位:grant select (id,name),update (age) on db1.t3 to ‘egon4‘@‘localhost‘ identified by ‘123‘; #可以在tables_priv和columns_priv中看到相應的許可權

  

執行個體:

create user ‘egon1‘@‘%‘ identified by ‘123‘;grant select on *.* to egon1;select * from user  where user=‘egon1‘;grant select on db1.* to egon1;select * from db where user=‘egon1‘;grant all on db1.t1 to egon1;select * from tables_priv where user=‘egon1‘;grant select (name) , update(age) on db1.t1 to egon1;select * from columns_priv where user=‘egon1‘;

  

 

 

 

mysql許可權管理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.