drop database if exists temp_mark; create database if not exists temp_mark; use temp_mark; create table test1 (i int); insert into test1 values (1),(2),(321),(4356); drop role if exists role_all; drop role if exists role_write; drop role if exists role_read; create role role_all; create role role_write; create role role_read; create role if not exists role_all; show warnings; GRANT ALL privileges on test1 to role_all; GRANT select on test1 to role_read; GRANT insert,update on test1 to role_write; drop user if exists all_user@localhost; drop user if exists read_user@localhost; drop user if exists write_user@localhost; CREATE USER all_user@localhost IDENTIFIED BY 'all'; CREATE USER read_user@localhost IDENTIFIED BY 'read'; CREATE USER write_user@localhost IDENTIFIED BY 'write'; GRANT role_all TO all_user@localhost; GRANT role_read TO read_user@localhost; GRANT role_write TO write_user@localhost;