当前位置:网站首页>mysql添加用户以及设置权限
mysql添加用户以及设置权限
2022-08-11 08:21:00 【raoxiaoya】
首先项目中肯定不能使用root账户,root用户只有运维人员才能使用,因此需要创建一个用于项目中的账户。
create user 'userchp'@'%' IDENTIFIED BY 'hyok^12(--m$pyuik';
一个新创建的用户没有任何权限,不能进行任何操作。
现在需要它只能对业务数据库进行增,删,改,查。
主要的权限
ALL: 所有可用的权限
CREATE: 创建库、表和索引
LOCK_TABLES: 锁定表
ALTER: 修改表
DELETE: 删除表
UPDATE: 更新数据
INSERT: 插入表或列
SELECT: 检索表或列的数据
CREATE_VIEW: 创建视图
SHOW_DATABASES: 列出数据库
DROP: 删除库、表和视图
赋权语句
GRANT <privileges> ON <database>.<table> TO 'userchp'@'%';
<privileges>
代表着用逗号分隔的权限列表。如果你想要将权限赋予任意数据库(或表),那么使用星号(*)来代替数据库(或表)的名字。例如
grant update,delete,insert,select ON chpay.* TO 'userchp'@'%';
验证给用户赋予的权限
show grants for 'userchp'@'%';
移除权限
revoke <privileges> ON <database>.<table> FROM 'userchp'@'%';
刷新权限使其生效
FLUSH PRIVILEGES;
删除用户
drop user 'userchp'@'%';
边栏推荐
- nodejs微服务中跨域,请求,接口,参数拦截等功能
- Do you know the basic process and use case design method of interface testing?
- Break pad source code compilation--refer to the summary of the big blogger
- 借问变量何处存,牧童笑称用指针,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang类型指针(Pointer)的使用EP05
- IQUNIX A80 exploring TTC金粉 初体验
- Mysql JSON对象和JSON数组查询
- Two startup methods and differences of Service
- Project 1 - PM2.5 Forecast
- Kotlin算法入门计算水仙花数
- The growth path of a 40W test engineer with an annual salary, which stage are you in?
猜你喜欢
LoRa芯片的特征
查找最新人员工资和上上次人员工资的变动情况
用 Antlr 重构脚本解释器
记录一些遇见的bug——Lombok和Mapstruct的冲突导致,A component required a bean of type ‘com.XXX.controller.converter.
小目标检测3_注意力机制_Self-Attention
Unity3D——自定义类的Inspector面板的修改
The softmax function is used in TF;
1081 Check Password (15 points)
Active users of mobile banking grew rapidly in June, hitting a half-year high
如何通过 IDEA 数据库管理工具连接 TDengine?
随机推荐
机器学习(三)多项式回归
Kotlin Algorithm Getting Started with Rabbit Number Optimization and Expansion
Kali penetration test environment set up
迷你图书馆系统(对象+数组)
快速幂,逆元的求解
借问变量何处存,牧童笑称用指针,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang类型指针(Pointer)的使用EP05
Creo9.0 特征的成组
Kotlin算法入门计算水仙花数
Kaldi语音识别工具编译问题记录(踩坑记录)
Write a resume like this, easy to get the interviewer
Break pad source code compilation--refer to the summary of the big blogger
企业服务器主机加固现状分析
Kotlin算法入门计算质因数
JRS303-Data Verification
jenkins简单使用
《剑指offer》题解——week3(持续更新)
Conditional statements in TF; where()
leetcode:69. x 的平方根
klayout--导出版图为gds文件
Notable NFT development trends in 2022