MariaDB [mysql]> create role test_ROLE;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [mysql]> create role test_role;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [mysql]> grant select on mysql.* to test_role;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [mysql]> select user, host from user where is_role='y' and user like 'test%';
|
+-----------+------+
|
| user | host |
|
+-----------+------+
|
| test_ROLE | |
|
| test_role | |
|
+-----------+------+
|
2 rows in set (0.00 sec)
|
|
MariaDB [mysql]> grant test_role to testuser;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [mysql]> show grants for testuser;
|
+------------------------------------------------------------------------+
|
| Grants for testuser@% |
|
+------------------------------------------------------------------------+
|
| GRANT test_role TO 'testuser'@'%' |
|
| GRANT USAGE ON *.* TO 'testuser'@'%' IDENTIFIED VIA pam USING 'mariadb' |
|
+------------------------------------------------------------------------+
|
2 rows in set (0.00 sec)
|
|
MariaDB [mysql]> grant test_ROLE to testuser;
|
ERROR 1961 (HY000): Cannot grant role 'test_ROLE' to: 'testuser'.
|
MariaDB [mysql]> show grants for testuser;
|
+------------------------------------------------------------------------+
|
| Grants for testuser@% |
|
+------------------------------------------------------------------------+
|
| GRANT USAGE ON *.* TO 'testuser'@'%' IDENTIFIED VIA pam USING 'mariadb' |
|
+------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [mysql]> select * from roles_mapping where user='testuser';
|
+-----------+---------+-----------+--------------+
|
| Host | User | Role | Admin_option |
|
+-----------+---------+-----------+--------------+
|
| % | testuser | test_role | N |
|
+-----------+---------+-----------+--------------+
|
3 rows in set (0.00 sec)
|
|
MariaDB [mysql]> flush privileges;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [mysql]> show grants for testuser;
|
+------------------------------------------------------------------------+
|
| Grants for testuser@% |
|
+------------------------------------------------------------------------+
|
| GRANT test_role TO 'testuser'@'%' |
|
| GRANT USAGE ON *.* TO 'testuser'@'%' IDENTIFIED VIA pam USING 'mariadb' |
|
+------------------------------------------------------------------------+
|
2 rows in set (0.00 sec)
|