Permission level for MySQL

Source: Internet
Author: User

MySQL has 5 levels of permissions, namely:
Clobal level,database level,table level,column level,routine level.

1,clobal level: It is the global permission for the entire MySQL database server. Permissions to a database in MySQL, or to a table in a database. All permissions information is present in the Mysql.user table.


Setting statements for global permissions:

GRANT all on * * to ' root ' @ ' localhost '

The first * represents the database name, this is all databases, and the second * represents the table name.
Global permissions have alter ALTER ROUTINE create all create ROUTINE create temporary TABLES create USER create VIEW DELETE all DROP all EX Ecute file All to file INDEX all inserts all LOCK TABLES PROCESS all RELOAD all REPLICATION CLIENT SLAVE STATUS Replicati On SLAVE SELECT show DATABASES show View View SHUTDOWN SUPER UPDATE USAGE


2,database level: Permissions at the database levels, set permissions through databasename.*. Set the statement as follows:

GRANT all on databasename.* to ' root ' @ ' localhost '
It will be overwritten with the permissions of the global level, such as the following two permission set statements:

GRANT SELECT on test.* to ' root ' @ ' localhost '; REVOKE SELECT on * * from ' root ' @ ' localhost ';
' Root ' @ ' localhost ' will no longer have SELECT permission on test.
Database permissions are: CREATE user,file,process,reload,replication client,replication slave,show databases,shutdown,super USAGE


3,table levels: Table-level permissions can be overridden by global permissions and database-level permissions

GRANT SELECT on test.test to ' root ' @ ' localhost '; SHOW GRANTS for ' root ' @ ' localhost ';
You can set permissions directly on a table name by using the use Select a database

GRANT SELECT on test to ' root ' @ ' localhost ';
The permissions for the table are: Alter,create,delete,drop,index,insert,select UPDATE


4,column level: The permissions for a column of a table. It will be overwritten by the previous three permissions

GRANT SELECT (ID) on the test to ' root ' @ ' localhost ';
Field-level permissions are Insert,select, UPDATE


5,routine level: It is for functions and stored procedure permissions, he will be a three-way permission to cover out.

GRANT EXECUTE on TEST.P to ' root ' @ ' localhost ';


Permission level for MySQL

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.