ITPub博客

首页 > 数据库 > MySQL > MySQL 5.7的角色功能

MySQL 5.7的角色功能

原创 MySQL 作者:ywxj_001 时间:2019-08-22 12:11:12 0 删除 编辑

MySQL 5.7的角色功能:

创建用户并授予用户角色功能:

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)



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22996654/viewspace-2654563/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
在零售、金融行业从事数据库相关工作10余年,有丰富的数据库管理的相关经验。 涉及SqlServer、Oracle、MySQL、PostgreSQL等多种数据库。 专注于各类数据库的研究。 目前在一家外资的上市零售公司担任资深DBA岗位。负责整个集团数据库的架构设计和管理。

注册时间:2010-01-19

  • 博文量
    113
  • 访问量
    90424