0 × 00 mysql user permissionsThe root user of mysql has the highest permissions. Run the command to view the permissions of the root user.
Show grants for root @ localhost // view root User Permissions + PRIVILEGES + | Grants for root @ localhost | + PRIVILEGES + | grant all privileges on *. * TO 'root' @ 'localhost' with grant option | grant proxy on ''@'' TO 'root' @ 'localhost' with grant option | + users +
As shown in the preceding output, root has all privileges, so we can list all permissions in privileges. 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 to do anything (same as root ). USAGE: Only Logon Allowed-nothing else is allowed.
0 × 01 permission settingsLog on to the root user and create a common user. The username and password are both leesec insert into mysql. user (Host, User, Password) values ('localhost', 'lesec', password ('lesec ')); next, we will set various control permissions on the database or table for the leesec user. 1. for the database leesec, the admin settings of the table only allow the query, modification, and insert permissions grant select, update, and insert on leesec. admin to leesec @ localhost identified by 'leessec '; then we log on to the leesec user and perform the delete record operation ERROR 1142 (42000) on the table admin ): DELETE command denied to user 'lesec' @ 'localhost' for table 'admin' 2. grant the mysql user leesec the permission to delete the table admin grant delete on leesec. admin to leesec @ localhost identified by 'lesec' 3. delete the delete permission revoke delete on leesec of the Mysql user. admin from leesec @ localhost; now you know the minimum permission settings