How to operate DCL in mysql database
Today, I would like to share with you the relevant knowledge points about how to operate DCL in mysql database. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
DCL
DCL (Data Control Language), database control language.
Main purpose: an instruction to control database access.
Manipulate commands: GRANT, REVOKE
GRANT: empower users.
REVOKE: reclaims user rights.
User management
The post-MYSQL8.0 version does not support the grant statement to create users directly, so you need to create users before authorizing them.
Create user CREATE USER 'username'@'hostname' IDENTIFIED BY' password
Case study:
Create user 'csg1' identified by' 123'
Users created with Create have only the system default permission usage and no other permissions.
Delete user DROP USER 'username'@'hostname'
Case study:
Drop user csg1
Rights management entitles GRANT priviledge_name [(list_name1,list?_name2)] ON dbname.table_name FROM 'username'@'hostname'
Case study:
Add the 'select' permission for all tables in the database' mysqlpractice' to the account 'csg1'.
Grant select on mysqlpractice.* to csg1
Case study:
Entitle all permissions to the entire database and table.
Grant all on *. * to dba@localhost; View permissions to view specified account permissions:
SHOW GRANTS FOR 'username'@'hostname'
View the current user's own permissions:
SHOW GRANTS; Recycling permission REVOKE priviledge_name [(list_name1,list?_name2)] FROM dbname.table_name FROM 'username'@'hostname'
Case study:
Revoke select on mysqlpractice.* from csg1
These are all the contents of the article "how to operate DCL in mysql database". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.