mysql中DCL常用的用户和权限控制是什么
作者:水悠悠予安
时间:2023-04-26
浏览:5
一、用户控制管理创建用户createuser'用户名'@'主机名'identifiedby'密码';修改用户密码alteruser'用户名'@'主机名'identifiedwithmysql_native_passwordby'密码';删除用户dropuser'用户名'@'主机名';例如:#1查询用户usemysql;select*fromuser;#2创建用户createuse
本文目录
一、用户控制管理
创建用户
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.*: *可以表示匹配任意数据,在数据库名,和表名中都可以使用。
作者最新文章
漫蛙2manwa2漫画最新版本下载安装
2026-10-13 13:42
漫蛙2台版入口极速直达
2026-10-13 13:17
免费漫蛙manwa官网入口
2026-10-13 13:15
漫蛙manwa漫画网址大全
2026-10-13 13:15
photoshop通道和蒙版在哪
2026-10-03 12:15
下一篇:
Java的hashcode方法如何使用
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多









































