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