2018-12-06 01:17:44 +01:00
|
|
|
use mysql;
|
|
|
|
insert db (db,user,select_priv) values ('foo','dwr_foo','Y'), ('bar','dwr_bar','Y');
|
|
|
|
insert roles_mapping (user,role) values ('dwr_qux_dev','dwr_foo'),('dwr_qux_dev','dwr_bar');
|
2018-12-07 15:13:39 +02:00
|
|
|
insert ignore user (user,show_db_priv,is_role) values ('dwr_foo','N','Y'), ('dwr_bar','N','Y'), ('dwr_qux_dev','Y','Y');
|
2018-12-06 01:17:44 +01:00
|
|
|
Warnings:
|
|
|
|
Warning 1364 Field 'ssl_cipher' doesn't have a default value
|
|
|
|
Warning 1364 Field 'x509_issuer' doesn't have a default value
|
|
|
|
Warning 1364 Field 'x509_subject' doesn't have a default value
|
|
|
|
Warning 1364 Field 'authentication_string' doesn't have a default value
|
|
|
|
flush privileges;
|
|
|
|
drop role dwr_foo;
|
|
|
|
drop role dwr_bar;
|
|
|
|
drop role dwr_qux_dev;
|
2019-03-30 12:52:23 +01:00
|
|
|
use test;
|
|
|
|
create table db_copy as select * from mysql.db;
|
|
|
|
delete from mysql.db;
|
|
|
|
flush privileges;
|
|
|
|
create user u1@localhost;
|
|
|
|
create role r1;
|
|
|
|
create role r2;
|
|
|
|
grant r1 to u1@localhost;
|
|
|
|
grant select on test.* to r2;
|
|
|
|
grant select on m_.* to r2;
|
|
|
|
grant r2 to r1;
|
|
|
|
show grants for u1@localhost;
|
|
|
|
Grants for u1@localhost
|
|
|
|
GRANT r1 TO 'u1'@'localhost'
|
|
|
|
GRANT USAGE ON *.* TO 'u1'@'localhost'
|
|
|
|
show grants for r1;
|
|
|
|
Grants for r1
|
|
|
|
GRANT r2 TO 'r1'
|
|
|
|
GRANT USAGE ON *.* TO 'r1'
|
|
|
|
GRANT USAGE ON *.* TO 'r2'
|
|
|
|
GRANT SELECT ON `test`.* TO 'r2'
|
|
|
|
GRANT SELECT ON `m_`.* TO 'r2'
|
|
|
|
drop user u1@localhost;
|
|
|
|
drop role r1, r2;
|
|
|
|
insert mysql.db select * from db_copy;
|
|
|
|
flush privileges;
|
|
|
|
drop table db_copy;
|