I have an RDS instance of MySQL 8.0.13 where I am trying to implement Roles based permissions so I don't have to create / alter each user individually.
Here is the code I am using...
GRANT ROLE_ADMIN ON *.* TO mymasteruser; -- Need to do this or line 5 doesn't work.
CREATE ROLE 'TEST_ROLE';
GRANT ALL PRIVILEGES ON test_data.* TO 'TEST_ROLE';
CREATE USER 'dev3'@'%' IDENTIFIED BY '$uper$ecretP@ssw0rd';
GRANT TEST_ROLE TO 'dev3'@'%';
FLUSH PRIVILEGES;
I don't get any error messages when I run the above code, but when I try to login to the db using dev3 I get an Access Denied for user 'dev3'@'%' to database 'test_data'.
When I run
SHOW GRANTS FOR TEST_ROLE
I get
GRANT USAGE ON *.* TO `TEST_ROLE`@`%`
GRANT ALL PRIVILEGES ON `test_data`.* TO `TEST_ROLE`@`%`
When I run
SHOW GRANTS FOR 'dev3'@'%'
I get
GRANT USAGE ON *.* TO `dev3`@`%`
GRANT `TEST_ROLE`@`%` TO `dev3`@`%`
It looks to me that all the correct permissions are in place, but I still get Access Denied.
I can give that user individual access as normal, just not through the role.
What am I doing wrong?
Thanks
经过一些研究,答案似乎正在运行
SET DEFAULT ROLE 'TEST_ROLE' TO 'dev3'@'%';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.