Introduction to DCL

1 Introduction

The full name of DCL in English is (Data Control Language), which is used to manage database users and control database access permissions.

2. DCL management users

  • Query user
Use mysql;
select * from user;
  • Create user
create user '用户名'@'主机名' Identified by '密码'
  • Change user password
alter user '用户名'@'主机名' identified with mysql_native_password by '新密码'
  • delete users
drop user '用户名'@'主机名'

MySQL user information is stored in the user table of the MySQL system database.

Insert image description here

3. DCL permission control

After creating a new user, its permissions will be restricted, causing many functions of the database to be unavailable. Here you can use DCL permission control statements to control the user's permissions. There are many permissions defined in mysql, but the most commonly used ones are as follows:

Permissions illustrate
ALL,ALL PRIVILEGES All permissions
Select Query data
Insert Insert data
update change the data
Delete delete data
alter Modify table
drop Delete database/table/view
create Create database/table
  • Query permissions
Show grants for '用户名'@'主机名'
  • Granted permission
grant 权限列表 on 数据库名.表名 to '用户名'@'主机名'
  • revoke permission
revoke 权限列表 on 数据库名.表名 from '用户名'@'主机名'

Guess you like

Origin blog.csdn.net/qq_43456605/article/details/132601009