code prettify

Monday 18 September 2017

MySQL 8 - Roles

With the next version of MySQL that is MySQL 8, there is a very nice feature of creating "roles" which can be assigned certain privileges and then these roles can be assigned to users, thus helping us in maintaining the principle of least privilege.



It makes our life as developers and DBAs easier as we do not have to remember what are the specific privileges assigned to different users. These "roles" can simply be assigned or de-assigned from users as necessary.

The setup process is pretty easy and intuitive.

1. Create Role:

CREATE ROLE 'read', 'write', 'read_write';

Which essentially creates a set of named roles which do not have any privileges assigned to them, as yet.

2. Grant/Assign Privileges to a Role:

GRANT SELECT ON sample_db.* TO 'read';

3. Assign Role to user:

GRANT 'read' TO 'john'@'localhost', 'mary'@'localhost';

Reference: https://dev.mysql.com/doc/refman/8.0/en/roles.html

2 comments:

  1. Estonia is an astonishing house of north of 4,800 IT organizations creating a yearly turnover of over €3.6 billion. Those Estonia programming area consultancy Estonia organizations offer counseling and advancement administrations to nearby clients as well as the re-appropriating administrations to north of 130 nations around the world. Estonian specialized school system is thought of as one of the top frameworks in Europe.

    Estonia is the principal country that utilizes e-casting a ballot, e-occupants, e-government, and numerous other computerized arrangements. All divisions of government energize neighborhood reevaluating of IT counseling administrations to give a superior climate to programming industry counseling organizations Estonia>> Mobilunity

    ReplyDelete