MySQL如何让GRANT扮演角色?它们仅对用户有效

时间:2019-07-25 09:59:36

标签: mysql

如果我将SELECT授予用户,则没有问题,但是如果我将SELECT授予角色,然后又将角色授予用户SELECT查询不起作用,即使使用'role'的'user'的SHOW GRANTS显示该用户有权选择

-以root身份

create role 'seller';
grant select on pharmacy.sells to 'seller';
create user 'seller1'@'localhost' identified by '1';
grant 'seller' to 'seller1'@'localhost'

-现已成为Seller1

select * from pharmacy.sells

--Error Code: 1142. SELECT command denied to user 'seller1'@'localhost' for table 'sells'

show grants for 'seller1'@'localhost' using 'seller'

--GRANT USAGE ON *.* TO `seller1`@`localhost`

--GRANT SELECT ON `pharmacy`.`sells` TO `seller1`@`localhost`

--GRANT `seller`@`%` TO `seller1`@`localhost`

-以root身份

grant select on pharmacy.sells to 'seller1'@'localhost'

-作为卖方1

select * from pharmacy.sells

-有效

-show Grants显示相同的内容

0 个答案:

没有答案