当前位置:网站首页>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'@'%';
边栏推荐
- matplotlib
- Filesystem Hierarchy Standard
- 【Day_13 0509】▲跳石板
- 场地预订系统,帮助场馆提高坪效
- 一根网线两台电脑传输文件
- Machine Learning Summary (2)
- Hibernate 的 Session 缓存相关操作
- My creative anniversary丨Thank you for being with you for these 365 days, not forgetting the original intention, and each is wonderful
- 分门别类输入输出,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang基本数据类型和输入输出EP03
- [C语言] sscanf如何实现sscanf_s?
猜你喜欢
随机推荐
Filesystem Hierarchy Standard
关于架构的认知
Four states of Activity
快速幂,逆元的求解
My creative anniversary丨Thank you for being with you for these 365 days, not forgetting the original intention, and each is wonderful
The easiest trick to support quick renaming of various files
囍楽cloud task source code
Keep track of your monthly income and expenses through bookkeeping
leetcode: 69. Square root of x
Kotlin算法入门兔子数量优化及拓展
Square, multi-power, square root calculation in Tf
兼容并蓄广纳百川,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang复合容器类型的声明和使用EP04
机器学习(一)数据的预处理
C Primer Plus(6) 中文版 第1章 初识C语言 1.7 使用C语言的7个步骤
2022-08-10 mysql/stonedb-slow SQL-Q16-time-consuming tracking
Unity3D - modification of the Inspector panel of the custom class
golang 字符串操作
【C语言】每日一题,求水仙花数,求变种水仙花数
Unity3D——自定义类的Inspector面板的修改
Redis 只会用缓存?20种妙用让同事直呼牛X(荣耀典藏版)








