create user 'junior'@'127.0.0.1' identified by '123'; Query OK, 0..."/>
溫馨提示×

溫馨提示×

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

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

MySQL 5.7的角色功能

發(fā)布時間:2020-08-04 16:30:29 來源:ITPUB博客 閱讀:281 作者:ywxj_001 欄目:MySQL數(shù)據(jù)庫

MySQL 5.7的角色功能:

創(chuàng)建用戶并授予用戶角色功能:

mysql> create user 'junior'@'127.0.0.1' identified by '123';

Query OK, 0 rows affected (0.01 sec)

mysql> create user 'tom'@'127.0.0.1' identified by '123';

Query OK, 0 rows affected (0.00 sec)

mysql> create user 'jim'@'127.0.0.1' identified by '123';

Query OK, 0 rows affected (0.01 sec)

mysql> grant proxy on 'junior'@'127.0.0.1' to 'tom'@'127.0.0.1';

Query OK, 0 rows affected (0.01 sec)

mysql> grant proxy on 'junior'@'127.0.0.1' to 'jim'@'127.0.0.1';

Query OK, 0 rows affected (0.00 sec)

mysql> grant select on *.* to 'junior'@'127.0.0.1';

Query OK, 0 rows affected (0.00 sec)

mysql> show grants for 'junior'@'127.0.0.1';

+---------------------------------------------+

| Grants for junior@127.0.0.1                 |

+---------------------------------------------+

| GRANT SELECT ON *.* TO 'junior'@'127.0.0.1' |

+---------------------------------------------+

1 row in set (0.00 sec)

mysql> show grants for 'jim'@'127.0.0.1';

+----------------------------------------------------------+

| Grants for jim@127.0.0.1                                 |

+----------------------------------------------------------+

| GRANT USAGE ON *.* TO 'jim'@'127.0.0.1'                  |

| GRANT PROXY ON 'junior'@'127.0.0.1' TO 'jim'@'127.0.0.1' |

+----------------------------------------------------------+

2 rows in set (0.00 sec)

mysql> show grants for 'tom'@'127.0.0.1';

+----------------------------------------------------------+

| Grants for tom@127.0.0.1                                 |

+----------------------------------------------------------+

| GRANT USAGE ON *.* TO 'tom'@'127.0.0.1'                  |

| GRANT PROXY ON 'junior'@'127.0.0.1' TO 'tom'@'127.0.0.1' |

+----------------------------------------------------------+

2 rows in set (0.00 sec)

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from proxies_priv;

+-----------+------+--------------+--------------+------------+----------------------+---------------------+

| Host      | User | Proxied_host | Proxied_user | With_grant | Grantor              | Timestamp           |

+-----------+------+--------------+--------------+------------+----------------------+---------------------+

| localhost | root |              |              |          1 | boot@connecting host | 0000-00-00 00:00:00 |

| 127.0.0.1 | tom  | 127.0.0.1    | junior       |          0 | root@localhost       | 0000-00-00 00:00:00 |

| 127.0.0.1 | jim  | 127.0.0.1    | junior       |          0 | root@localhost       | 0000-00-00 00:00:00 |

+-----------+------+--------------+--------------+------------+----------------------+---------------------+

3 rows in set (0.00 sec)

向AI問一下細節(jié)

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

AI