Database Reference
In-Depth Information
The output of the
SHOW GRANTS
command is a
GRANT
statement that encapsulates all
of the user's privileges. This is useful if you want to give another user the exact same
privileges. For example, the output of the preceding
SHOW GRANTS
command might
be as follows:
+------------------------------------------------------+
| Grants for dieter@10.2.200.4 |
+------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'dieter'@'10.2.200.4' |
+------------------------------------------------------+
Changing passwords
To change the password of a user, we use the
SET PASSWORD
statement. It has the
following pattern:
SET PASSWORD FOR <user> = PASSWORD('<password>');
Here is an example:
SET PASSWORD FOR 'henry'@'%' = PASSWORD('niftypassword');
Complete documentation of the
SET PASSWORD
statement is available at
https://mariadb.com/kb/en/set-password/
.
Removing users
To remove a user completely, we use the
DROP USER
statement. It has the
following pattern:
DROP USER <user>;
Here is an example:
DROP USER 'tom'@'%';
When a user is dropped, all grants are automatically removed.
Complete documentation of the
DROP USER
statement is available at
https://mariadb.com/kb/en/drop-user/
.