MySQL 許可權管理的注意事項

來源:互聯網
上載者:User
    ㈠ 認證和授權
   
   
   認證:who am I ?
   授權:what I can do ?
   
   認證實際上就是一個驗證憑證的過程、而進入MySQL 需要出示的憑證有:host、username、password 
   
   串連MySQL 常見有 2 種:
   
   ① TCP/IP 串連
      

      加 -h 參數、通過TCP/IP 串連MySQL 執行個體、mysql.user 對來者進行認證

      顯然、對於TCP/IP 這種請求、MySQL 是要求您出示憑證的

      
   ② Socket 
      
      -S 參數 、只能在 MySQL 用戶端和執行個體在同一台伺服器上使用
      
     
     
     

   ㈡ 預設有 2 個高危險使用者:

                 

   ㈢ % 不是萬能的、至少無法替代 localhost、而 MySQL 預設卻是以 localhost登陸

mysql> grant all on *.* to 'david'@'%' identified by 'oracle';Query OK, 0 rows affected (0.05 sec)[mysql@odd ~]$ mysql -udavid -poracleERROR 1045 (28000): Access denied for user 'david'@'localhost' (using password: YES)[mysql@odd ~]$ mysql -udavid -poracle -h 127.0.0.1ERROR 1045 (28000): Access denied for user 'david'@'localhost' (using password: YES)mysql> grant all on *.* to 'david'@'localhost' identified by 'oracle';Query OK, 0 rows affected (0.01 sec)[mysql@odd ~]$ mysql -udavid -poracleWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 9Server version: 5.5.16-log Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

   ㈣ 什麼時候使用 FLUSH PRIVILEGES
   
   
   先認清 2 個事實:
   ● MySQL 許可權庫 mysql 永駐記憶體
   ● FLUSH PRIVILEGES會強行重新整理記憶體中的許可權資訊
   
   要做:
   直接對mysql 下的grant tables 進行DML、要做!
   
   不做:
   grant、revoke、create user、drop user 、不做!
   
   
   ㈤ 許可權等級的那些事兒
   
            ⑴ 許可權等級及文法規則

                 

   
        2 點補充:
   
          ① GRANT ALL 可授予某個Level 的所有可用許可權
          ② WITH GRANT OPTION 子句可級聯授權
   
   
      ⑵ 生效時間
   
         Global Level 或 Database Level 許可權變更後、需先 KILL 重串連
         Table Level 或 Column Level 變更立即生效
   
   
      ⑶ 校正順序

                 

                ⑷ 對應的 grant tables

   

         Globa Level     ←●→     mysql.user

         Database Level  ←●→     mysql.db

         Table Level     ←●→     mysql.table_priv

         Column Level    ←●→     mysql.column_priv

                    
                    By David lin
                    2013-05-31 
                    Good Luck

相關文章

聯繫我們

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