溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

數(shù)據(jù)庫常用授權(quán)和授權(quán)回收參數(shù)配置

發(fā)布時(shí)間:2020-07-10 09:55:37 來源:網(wǎng)絡(luò) 閱讀:373 作者:薛偉博 欄目:MySQL數(shù)據(jù)庫

標(biāo)題索引


  • 官方幫助

  • 常用案例


官方幫助

    在使用數(shù)據(jù)庫時(shí)必不可少的即是查看help幫助,通過help幫助再次尋找常用命令及參數(shù),如下為help grant信息:

MariaDB [(none)]> help grant;
Name: 'GRANT'
Description:
Syntax:
GRANT
    priv_type [(column_list)]
      [, priv_type [(column_list)]] ...
    ON [object_type] priv_level
    TO user_specification [, user_specification] ...
    [REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}]
    [WITH with_option ...]

GRANT PROXY ON user_specification
    TO user_specification [, user_specification] ...
    [WITH GRANT OPTION]

object_type:
    TABLE
  | FUNCTION
  | PROCEDURE

priv_level:
    *
  | *.*
  | db_name.*
  | db_name.tbl_name
  | tbl_name
  | db_name.routine_name
user_specification:
    user
    [
        IDENTIFIED BY [PASSWORD] 'password'
      | IDENTIFIED WITH auth_plugin [AS 'auth_string']
    ]
Normally, a database administrator first uses CREATE USER to create an
account, then GRANT to define its privileges and characteristics. For
example:

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';
GRANT USAGE ON *.* TO 'jeffrey'@'localhost' WITH MAX_QUERIES_PER_HOUR 90;

常用配置

    1.授權(quán)單位普通DBA或運(yùn)維人員增刪改查命令

MariaDB [(none)]> create table performance( id int, server_name varchar(20), Adress_City varchar(30) );
MariaDB [(none)]> grant select,update,delete,insert on cluster.performance to root@'172.18.0.%' identified by 'jncsy';
Query OK, 0 rows affected (0.00 sec)
MariaDB  [(none)]> flush privileges;

    2.授權(quán)某個(gè)用戶某張表的某幾列查詢命令

MariaDB [(none)]> grant select(id,server_name) on cluster.performance to root@'172.18.0.%' identified by 'jncsy';
Query OK, 0 rows affected (0.00 sec)
MariaDB  [(none)]> flush privileges;

    3.撤銷某用戶的授權(quán)權(quán)限

MariaDB [(none)]> show grants for root@'172.18.0.%';
+--------------------------------------------------------------------------------------------------------------+
| Grants for root@172.18.0.%                                                                                   |
+--------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'172.18.0.%' IDENTIFIED BY PASSWORD '*429B3FB345D35EC8C8B54230AD060C07E846494A' |
| GRANT SELECT, INSERT, UPDATE, DELETE ON `cluster`.`performance` TO 'root'@'172.18.0.%'                       |
+--------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]> revoke select on cluster.performance from root@'172.18.0.%';
Query OK, 0 rows affected (0.00 sec)


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI