您的位置:首页 >mysql中DCL常用的用户和权限控制是什么
发布于2023-04-26 阅读(0)
扫一扫,手机访问
创建用户
create user '用户名'@'主机名' identified by '密码';
修改用户密码
alter user '用户名'@'主机名' identified with mysql_native_password by '密码';
删除用户
drop user '用户名'@'主机名';
例如:
#1 查询用户 use mysql; select * from user; #2 创建用户 create user 'root'@'localhost' identified by '123456'; #3 修改用户密码 alter user 'root'@'localhost' identified with mysql_native_password by '1234'; #4 删除用户 drop user 'root'@'localhost';
注意:
localhost: 表示匹配本地主机
%: 表示可以匹配任意主机
查询权限
show grants for '用户名'@'主机号';
授予权限
grant 权限列表 on 数据库名.表名 to '用户名'@'主机号';
删除权限
revoke 权限列表 on 数据库名.表名 from '用户名'@'主机号';
例如:
# 查询权限 show grants for 'root'@'localhost'; # 授予权限 grant all on test.* to 'root'@'localhost'; # 删除权限 revoke all on test.* from 'root'@'localhost';
注意:
all: 可以表示授予全部权限。
test.*: *可以表示匹配任意数据,在数据库名,和表名中都可以使用。
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
9