How can I view MySQL user permissions? The following describes how to view MySQL user permissions and the statements that grant MySQL user permissions for your reference.
View MySQL user permissions:
Show grants for your users
For example:
Show grants for root @ 'localhost ';
Grant usage
Grant usage on *. * TO 'discuz' @ 'localhost' identified by password' * c242ddd213be9c6f8da28d4245bf69fc79a86eb ';
Grant all privileges on 'discuz'. * TO 'discuz' @ 'localhost ';
Let me explain the meaning of the above two sentences according to my understanding.
Create a user name that can only be logged on locally. The discuz password is ***** encrypted.
In the second sentence, grant the discuz user all the permissions to operate the discuz database.
Use GRANT
The GRANT command is used to create a new user, specify the user password, and add user permissions. The format is as follows:
Mysql> GRANT <privileges> ON <what>
-> TO <user> [identified by "<password>"]
-> [With grant option];
As you can see, this command contains a lot of content to be filled in. Let's introduce them one by one, and finally give some examples to give you an understanding of their collaborative work.
<Privileges> is a comma-separated list of MySQL user permissions you want to grant. You can specify three types of permissions:
Database/data table/data column permissions: Alter: Modify existing data tables (such as adding/deleting columns) and indexes.
Create: Create a new database or data table.
Delete: Delete table records.
Drop: delete a data table or database.
INDEX: Create or delete an INDEX.
Insert: Add Table records.
Select: displays/searches for table records.
Update: Modify existing records in the table.
Global Management of MySQL user permissions:
File: read and write files on the MySQL server.
PROCESS: displays or kills service threads of other users.
RELOAD: RELOAD Access Control tables and refresh logs.
SHUTDOWN: Shut down the MySQL service.
Special permissions:
ALL: allow anything (same as root ).
USAGE: Only logon is allowed. Other operations are not allowed.
Statements that grant MySQL user permissions
Provides you with an in-depth understanding of MySQL permission management.
Mysql index Comparison Analysis
Use of MySQL EXPLAIN statements
MySQL database connection command