MySQL permission management

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.