mysql权限设置
类别:数据库 浏览量:1124
时间:2016-9-8 mysql权限设置
mysql权限设置一、MySQL中为普通数据用户设置查询、插入、更新、删除 数据库中所有表数据的权利
grant select on testdb.* to common_user@'%'
grant insert on testdb.* to common_user@'%'
grant update on testdb.* to common_user@'%'
grant delete on testdb.* to common_user@'%'
或者,用一条 MySQL 命令来替代
grant select, insert, update, delete on testdb.* to common_user@'%'
二、MySQL中为 数据库开发人员设置创建表、索引、视图、存储过程、函数等权限
1、grant 创建、修改、删除 MySQL 数据表结构权限
grant create on testdb.* to developer@'192.168.0.%';
grant alter on testdb.* to developer@'192.168.0.%';
grant drop on testdb.* to developer@'192.168.0.%';
2、操作 MySQL 外键权限
grant references on testdb.* to developer@'192.168.0.%';
3、操作 MySQL 临时表权限
grant create temporary tables on testdb.* to developer@'192.168.0.%';
4、操作 MySQL 索引权限
grant index on testdb.* to developer@'192.168.0.%';
5、操作 MySQL 视图、查看视图源代码权限
grant create view on testdb.* to developer@'192.168.0.%';
grant show view on testdb.* to developer@'192.168.0.%';
6、操作 MySQL 存储过程、函数权限
grant create routine on testdb.* to developer@'192.168.0.%'; -- now, can show procedure status
grant alter routine on testdb.* to developer@'192.168.0.%'; -- now, you can drop a procedure
grant execute on testdb.* to developer@'192.168.0.%';
三、MySQL 常用设置权限
1、grant 作用在整个 MySQL 服务器上
grant select on *.* to dba@localhost; -- dba 可以查询 MySQL 中所有数据库中的表。
grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有数据库
2、grant 作用在单个数据库上
grant select on testdb.* to dba@localhost; -- dba 可以查询 testdb 中的表。
3、grant 作用在单个数据表上
grant select, insert, update, delete on testdb.orders to dba@localhost;
在给一个用户授权多张表时,可以多次执行以上语句。例如:
grant select(user_id,username) on smp.users to mo_user@'%' identified by '123345';
grant select on smp.mo_sms to mo_user@'%' identified by '123345';
4、grant 作用在表中的列上
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5、grant 作用在存储过程、函数上
grant execute on procedure testdb.pr_add to 'dba'@'localhost'
grant execute on function testdb.fn_add to 'dba'@'localhost'
四、查看 MySQL 用户权限
1、查看当前用户(自己)权限
show grants;
2、查看其他 MySQL 用户权限
show grants for dba@localhost;
五、撤销已经赋予给 MySQL 用户权限的权限
revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可,例如:
grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;
标签:mysql
您可能感兴趣
- mysql学习之索引介绍及其原理(MySQL学习教程之聚簇索引)
- 图片如何存放在mysql中(将图片保存到mysql数据库并展示在前端页面的实现代码)
- mysql数值类型图解(详解mysql持久化统计信息)
- mysqltimestamp如何比较(为什么MySQL 使用timestamp可以无视时区问题.)
- mysql服务器端安装步骤(windows下jsp+mysql网站环境配置方法)
- mysql 查询都是0的值(MySQL按小时查询数据,没有的补0)
- 阿里云的自带mysql怎么开启(阿里云云服务器mysql密码找回的方法)
- 阿里云mysql如何接入(阿里云服务器安装Mysql数据库的详细教程)
- mysql日志使用(MySQL 日志相关知识总结)
- mysql日常运维(MySQL从库维护经验分享)
- mysql 8.0.22 winx64安装配置方法图文教程(mysql 8.0.22 winx64安装配置方法图文教程)
- mysql数据库如何删除重复记录(mysql数据库删除重复数据只保留一条方法实例)
- 查看mysql所有权限(MySQL 权限控制细节分析)
- 织梦源码安装数据库怎么填(Mysql修改端口号 织梦DedeCMS设置教程)
- mysql索引失效的几种情况(Mysql 5.6 "隐式转换"导致的索引失效和数据不准确的问题)
- mysqlsql语句的优化(MySQL优化之如何写出高质量sql语句)
- 阿里最新财报公布 三季度营收增长3 ,将增加150亿美元回购额度 在美股价小涨(阿里最新财报公布)
- 赵薇时胖时瘦 最近变美少女 原因在这里 躺着就变瘦(赵薇时胖时瘦最近变美)
- 学会这26种姿势,你就可以和兵哥哥切磋了(你就可以和兵哥哥切磋了)
- 吴彦祖陈冠希 恩怨 ,失去曾让他流泪的女友,终遇走过18年真爱(吴彦祖陈冠希恩怨)
- 痴情男神 吴彦祖 与妻子恋爱8年,结婚10年,家庭幸福美满(痴情男神吴彦祖)
- 成功破圈,小牛电动SQi强势开 跨(小牛电动SQi强势开)
热门推荐
- mysql常用优化方法(理解MySQL查询优化处理过程)
- mysql8.0使用(MySQL 8.0新特性 — 检查性约束的使用简介)
- 卸载了云服务器后怎么办(云服务器怎么还原被删除的数据?)
- uni app 小程序全局样式没法用(uniapp封装小程序雷达图组件的完整代码)
- 微信小程序苹果部分内容打不开(微信小程序audio组件在ios端无法播放的解决办法)
- SQL SERVER中查看某个时间段内出错的作业
- nginx代理转发域名(Nginx域名转发使用场景代码实例)
- python 字典按key值排序(Python 按字典dict的键排序,并取出相应的键值放于list中的实例)
- pythonexcel生成报表(python生成每日报表数据Excel并邮件发送的实例)
- mysql的count知识(MySQL中MTR的概念)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9