当前位置:网站首页>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'@'%';
边栏推荐
- Swagger简单使用
- 1.1-Regression
- JUC并发编程
- Unity3D - modification of the Inspector panel of the custom class
- Analysis of the Status Quo of Enterprise Server Host Reinforcement
- Do you know the basic process and use case design method of interface testing?
- 2022年值得关注的NFT发展趋势
- Openlayers Aggregate Graph, Weight Aggregate Graph, and Aggregate Graph Click Events
- About # SQL problem: how to set the following data by commas into multiple lines, in the form of column display
- 【实战系列】OpenApi设计规范
猜你喜欢
TF generates (feature, label) set through feature and label, tf.data.Dataset.from_tensor_slices
查询跟踪快递单号物流,智能分析物流中转有延误的单号
3.2 - classification - Logistic regression
Find the latest staff salary and the last staff salary changes
About # SQL problem: how to set the following data by commas into multiple lines, in the form of column display
The softmax function is used in TF;
JUC Concurrent Programming
Active users of mobile banking grew rapidly in June, hitting a half-year high
[C语言] sscanf如何实现sscanf_s?
JRS303-数据校验
随机推荐
Hibernate 的 Session 缓存相关操作
Creo9.0 特征的成组
2022 China Soft Drink Market Insights
go sqlx 包
Kotlin算法入门计算质因数
Alibaba Sentinel - Slot chain解析
如何仅更改 QGroupBox 标题的字体?
1.1-Regression
Dynamic Agent Learning
pyqt5实现仪表盘
欧拉函数(用欧拉筛法求欧拉函数)
剑指offer专项突击版第26天
【Day_13 0509】▲跳石板
8、Mip-NeRF
Kotlin算法入门求完全数
抽象类和接口
Unity3D - modification of the Inspector panel of the custom class
Four operations in TF
分门别类输入输出,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本数据类型和输入输出EP03
你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06