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 bk@localhost
.
Let's check the privileges the user bk@localhost
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 bk@localhost;
So, let's give bk@localhost 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.
Let's give him third permission which is to update age in the users table inside classDB DB.
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 bk@localhost
.
Let's create another user and grant him all permissions (making super user) (bad idea though): grant all privileges on *.* to amit@localhost with grant option;
Let's login with amit's account: