View User Permissions
Show grants for your users
For example:
Show grants for root @ 'localhost ';
Mysql has five permission levels: global level, database level, table level, column level, and routine level. High-level permissions cover low-level permissions.
Grant and revoke permissions to users
Grant select, UPDATE, DELETE, insert on *. * TO 'def '@ 'localhost ';
Revoke select, UPDATE, DELETE, insert on *. * FROM 'def '@ 'localhost ';
Permission-related tables are stored in mysql databases, including user, db, host, tables_priv, columns_priv, procs_priv, and proxies_priv.
-- View Current User
Select user ();
-- View All Users
SELECT host, user, password FROM mysql. user order by user;
First, we need to know when the MySQL permission information stored in the memory structure is updated: flush privileges will force MySQL to update the permission information loaded into the memory; the GRANT, REVOKE, create user, and drop user operations directly update the permission information in the memory. Restarting MySQL allows MySQL to read permission information from grant tables.
When will the updated permission information in the memory structure take effect for connected users? Modifications to the Global Level permission information will only be used after new connections are created. Sessions connected to the Global Level will not be affected. The modification of the Database Level permission information will only USE the new permission information in the re-verification after the "USE database_name" command is executed in the client request. So sometimes, after the urgent change of permissions for the Global and Database levels, you may need to run the "KILL" command to KILL sessions already connected to MySQL and force them to reconnect to use the updated permissions. The Table Level and Column Level permissions take effect the next time the Query that requires this permission is requested. That is to say, for applications, the permissions of these two levels are, the update takes effect immediately without executing the "KILL" command.