User Accounts and Grant Privileges

There are some defaults users in the MySQL databases. Let's look at them:

Let's create an account in the database: create user 'bk'@'localhost' identified by '123456' where 123456 is the password of the user [email protected].

Let's check the privileges the user [email protected] has. The first star shows the full access to all the databases and the second star indicates full access to all the tables inside those databases but he doesn't have any privilege now: show grants for [email protected];

So, let's give [email protected] some specific permission, in this case, we shall give him first permission to run select on any database and any table. And, the second permission is to insert in users table in classDB.

granting select and insert permissions to bk

Let's give him third permission which is to update age in the users table inside classDB DB.

granting update permission

Now I think I shouldn't have give Mr. BK the insert permission, he is doing some nasty things in the DB. So I now need to revoke the insert permission right away. To do this, revoke insert on classDB.users from [email protected].

revoking the insert permission

Let's create another user and grant him all permissions (making super user) (bad idea though): grant all privileges on *.* to [email protected] with grant option;

a user with all permissions.

Let's login with amit's account: