Mysql permission level

Source: Internet
Author: User

Mysql permission level
Mysql has five levels of permissions:
Clobal Level, Database Level, Table level, Column Level, and Routine Level.

1. Clobal Level: Global permissions for the entire mysql database server. Permission on a database in mysql or a table in a database. All permission information is stored in the mysql. user table.

Global permission setting statement:

GRANT ALL ON *.* to 'root'@'localhost'
The first * indicates the database name. Here it is all databases, and the second * indicates the table name.
Global permissions include alter routine create all create routine create temporary tables create user create view delete All DROP All execute file All into file index All INSERT All lock tables process All RELOAD All REPLICATION CLIENT SLAVE STATUS REPLICATION SLAVE SELECT SHOW DATABASES SHOW VIEW SHUTDOWN SUPER UPDATE USAGE

2. Database Level: Database-Level permissions. You can use databasename. * To Set permissions. The setting statement is as follows:

GRANT ALL ON databasename.* to 'root'@'localhost'
It will be overwritten by the global level permissions. For example, there are two permission setting statements:
GRANT SELECT on test.* to 'root'@'localhost';REVOKE SELECT ON *.* FROM 'root'@'localhost';
'Root' @ 'localhost' will no longer have the select permission on test.
Database permissions: create user, FILE, PROCESS, RELOAD, replication client, replication slave, show databases, SHUTDOWN, SUPER USAGE

3. Table Level: Table-Level permissions can be overwritten by global and database-Level permissions.

GRANT SELECT ON test.test to 'root'@'localhost';SHOW GRANTS FOR 'root'@'localhost';
You can use to select a database and directly set permissions for the table name.
GRANT SELECT ON test to 'root'@'localhost';
Table permissions include ALTER, CREATE, DELETE, DROP, INDEX, INSERT, select update.

4. Column Level: permission for a Column in a table. It will be overwritten by the first three permissions.

GRANT SELECT(id) ON test to 'root'@'localhost';
Field-level permissions include INSERT, SELECT, and UPDATE.

5. Routine Level: it is the permission for functions and stored procedures. It will be overwritten by 1, 2, and 3 permissions.

GRANT EXECUTE ON test.p to'root'@'localhost';

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.