Granting, revoking, and showing permissions
By default, new users do not have the permission to do anything except logging in, which is not very useful. So the next thing we need to do is give them the permissions that they need. Over time, we may need to remove or revoke the privileges we gave them earlier, and from time to time we'll want to look up a user to see what privileges they have.
Granting permissions
This is done using the
GRANT
statement. Using this statement, we will be able to GRANT
users the appropriate permissions. GRANT
statements have the following basic pattern:
GRANT <privileges> ON <database> TO <user>;
We customize the <privileges>
, <database>
, and <user>
parts as needed. The <user> section should match the 'username'@'host'
part of the CREATE
statement. Otherwise, we'll be creating a new user. We can also add an IDENTIFIED BY 'password'
section to the end of the GRANT
statement if we want to change the password of the user...