mysql中DCL常用的用户和权限控制
作者:Le`soleil 时间:2024-01-14 06:26:53
前言
本文总结了mysql中DCL,常用的一些权限控制,后续使用到其他会继续补充。
一、用户控制管理
创建用户
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.*: *可以表示匹配任意数据,在数据库名,和表名中都可以使用。
三、 数据库权限列表
请参考官方文档
来源:https://blog.csdn.net/weixin_45118229/article/details/123814482
标签:mysql,DCL,权限控制
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
PHP cookie,session的使用与用户自动登录功能实现方法分析
2023-11-21 15:00:43
flask项目集成swagger的方法
2022-08-04 09:00:48
![](https://img.aspxhome.com/file/2023/1/68381_0s.png)
引用其它js时如何同时处理多个window.onload事件
2024-04-16 10:31:47
python matlibplot绘制3D图形
2023-05-21 18:47:36
![](https://img.aspxhome.com/file/2023/4/87724_0s.png)
MySQL实现分布式锁
2024-01-25 19:31:03
![](https://img.aspxhome.com/file/2023/9/74849_0s.png)
Python通过调用mysql存储过程实现更新数据功能示例
2024-01-25 11:28:51
Python字符串本身作为bytes进行解码的问题
2022-12-22 07:18:42
在CentOS7下安装Python3教程解析
2021-09-17 16:51:13
![](https://img.aspxhome.com/file/2023/9/131539_0s.png)
gin 获取post请求的json body操作
2023-04-22 13:47:30
在Python下进行UDP网络编程的教程
2021-10-16 08:08:20
![](https://img.aspxhome.com/file/2023/0/133420_0s.png)
python3 enum模块的应用实例详解
2023-12-12 05:21:46
Python利用Turtle库绘制一个小老虎
2023-06-13 11:35:02
![](https://img.aspxhome.com/file/2023/8/81488_0s.jpg)
Python爬虫自动化获取华图和粉笔网站的错题(推荐)
2023-08-14 02:05:42
![](https://img.aspxhome.com/file/2023/8/124288_0s.png)
ASP在线升级类文件源码
2008-10-10 13:09:00
:hover在IE6下的问题
2009-06-18 21:09:00
Python中logging日志模块代码调试过程详解
2021-03-13 05:40:32
java-SSH2实现数据库和界面的分页
2024-01-27 16:17:19
python实现图片插入文字
2021-11-02 20:32:09
![](https://img.aspxhome.com/file/2023/7/120417_0s.jpg)
Python 提取dict转换为xml/json/table并输出的实现代码
2021-01-26 17:56:17
PHP Ajax JavaScript Json获取天气信息实现代码
2023-11-20 20:51:27
![](https://img.aspxhome.com/file/2023/1/89731_0s.jpg)