当前位置:网站首页>DCL statement of MySQL Foundation

DCL statement of MySQL Foundation

2022-07-04 10:21:00 Java full stack preacher

DCL(Data Control Language) sentence : Data control statement .

purpose : Control database 、 surface 、 Field 、 User Access and security levels .

Common keywords :grant、revoke etc.

It is generally used to manage the permissions of databases and users ​, Learn from practical examples grant( Assign permissions ) and  revoke( Take back authority )

Take a common example , This example will be useful in the future

Example : Assign permissions to a user for a database

The database server in a company may run databases of many projects at the same time . therefore , We should be able to Create different users according to different projects , Assign different permissions To manage and maintain the database .

create user 'usertest'@'%' indentified by '123456';
grant all privileges on mydb.* to 'usertest'@'%';

-- View the user's permissions 
show grants for 'usertest'@'%';

user usertest Yes mydb The database has all permissions (ALL PRIVILEGES)

Revoke delete permission

revoke delete on mydb.* from 'usertest'@'%'

Switch back to the root, Re execution revoke command

-- View the user's permissions 
show grants for 'usertest'@'%';

In addition to deleting permissions , Other permissions are . You can also see here , A user has many operation permissions ​, And these permissions can be assigned independently .​

Pay attention to the official account, learn more about the knowledge of the database and get the database free e-book. .

原网站

版权声明
本文为[Java full stack preacher]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141420588789.html