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';