MySQL 赋予用户权限命令的简单格式可概括为:grant 权限 on 数据库对象 to 用户

一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。 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@'%'

二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。 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.%' ;

grant 操作 MySQL 外键权限。

grant references on testdb.* to developer@'192.168.0.%' ;

grant 操作 MySQL 临时表权限。

grant create temporary tables on testdb.* to developer@'192.168.0.%' ;

grant 操作 MySQL 索引权限。

grant index on  testdb.* to developer@'192.168.0.%' ;

grant 操作 MySQL 视图、查看视图源代码 权限。

grant create view on testdb.* to developer@'192.168.0.%' ; grant show   view on testdb.* to developer@'192.168.0.%' ;

grant 操作 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.%' ; 三、grant 普通 DBA 管理某个 MySQL 数据库的权限。 grant all privileges on testdb to dba@'localhost' 其中,关键字 “privileges” 可以省略。

四、grant 高级 DBA 管理 MySQL 中所有数据库的权限。 grant all on *.* to dba@'localhost'

五、MySQL grant 权限,分别可以作用在多个层次上。 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 ;

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 用户权限 查看当前用户(自己)权限:

show grants; 查看其他 MySQL 用户权限:

show grants for dba@localhost; 七、撤销已经赋予给 MySQL 用户权限的权限。 revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:

grant  all on *.* to   dba@localhost; revoke all on *.* from dba@localhost; 八、MySQL grant、revoke 用户权限注意事项 1. grant, revoke 用户权限后,该用户只有重新连接 MySQL 数据库,权限才能生效。

2. 如果想让授权的用户,也可以将这些权限 grant 给其他用户,需要选项 “grant option“

grant select on testdb.* to dba@localhost with grant option; 这个特性一般用不到。实际中,数据库权限最好由 DBA 来统一管理。

转自

创建MySQL用户 赋予某指定库表的权限 - Alfa - 博客园 https://www.cnblogs.com/wuyifu/p/7580494.html

MySQL用户授权【转】的更多相关文章

  1. mysql用户授权、数据库权限管理、sql语法详解

    mysql用户授权.数据库权限管理.sql语法详解 —— NiceCui 某个数据库所有的权限 ALL 后面+ PRIVILEGES SQL 某个数据库 特定的权限SQL mysql 授权语法 SQL ...

  2. MySQL用户授权 和 bin-log日志 详解和实战(http://www.cnblogs.com/it-cen/p/5234345.html)

    看 了上一篇博文的发布时间,到目前已经有三个月没更新博文了.这三个月经历了很多事情,包括工作.生活和感情等等.由于个人发展的原因,这个月准备换工作 啦.在这段时间,我会把Web大型项目中所接触到的技术 ...

  3. MySQL用户授权 和 bin-log日志 详解和实战

    看了上一篇博文的发布时间,到目前已经有三个月没更新博文了.这三个月经历了很多事情,包括工作.生活和感情等等.由于个人发展的原因,这个月准备换工作啦.在这段时间,我会把Web大型项目中所接触到的技术都总 ...

  4. mysql用户授权及数据备份恢复

    用户授权与权限撤销 修改数据库管理员从本机登陆的密码测试: mysqladmin -hlocalhost -uroot -p password "新密码" Enter passwo ...

  5. MySQL用户授权

    一.授权语法格式  grant 权限列表 on 数据库名.表名 to '用户名'@'客户端主机' [identified by '密码']; 单词: privileges [ˈprivilidʒz] ...

  6. mysql用户授权以及权限收回

    语法 GRANT privileges [(columns)] ON DATABASE.TABLE TO 'username'@'hostname' [IDENTIFIED BY [PASSWORD] ...

  7. MySQL用户授权与权限

    MySQL权限如下表 权限名字 权限说明 Context CREATE 允许创建新的数据库和表 Databases, tables, or indexes DROP 允许删除现有数据库.表和视图 Da ...

  8. mysql 用户授权命令

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_root_password' WITH GRANT OP ...

  9. python mysql 视图 触发器 事物 存储过程 用户授权 数据备份还原

    ###################总结########### 视图是一个虚拟表(非真实存在) 是跑在内存中的表,真实表是在硬盘上的表 使用视图我们可以把查询过程中的临时表摘出来,保存下来,用视图去 ...

随机推荐

  1. Win7下mysql的安装

    一.简述 mysql与oracle相比小,便宜,装机量大,下载地址:https://www.mysql.com/downloads/,去找Community Edition,然后根据自己的Window ...

  2. C#设计模式(5)——建造者模式

    1.建造者模式介绍 在软件开发中,有时我们要创建一个复杂的对象,这个对象由几个子部件按一定的步骤组合而成,这时候我们就可以使用建造者模式了.说到建造者我们首先想到的是盖房子,盖房子简单的说有三个步骤: ...

  3. Linux 检查 外部设备 是否存在

    以 USB 为例,如果移植了udev,那么在usb插入的时候,/dev下面会出现usb有关的设备,同时,自动挂载到文件系统的某个节点 如果以文件系统usb对应的挂载点来检测USB是否插入,是不够严谨的 ...

  4. Elasticsearch分片优化

    原文地址:https://qbox.io/blog/optimizing-elasticsearch-how-many-shards-per-index 大多数ElasticSearch用户在创建索引 ...

  5. HDU 6362(求椭圆中矩形周长的期望 数学)

    题意是给定一个椭圆标准方程的a,b(椭圆的长半轴长和短半轴长),在[0,b]内取一个数,则过点(0,b)且平行于x轴的直线与椭圆交于两点,再将此两点关于x轴做对称点,顺次连接此四点构成矩形,求出这些矩 ...

  6. java位运算(&、|、 ~、>>、>>> 、 ^)

    1.& 与 数字按位进行与运算 101101 110111 100101 2.| 或 数字按位进行或运算 3.~ 非 数字按位取反 4.>> 右移 数字按位进行右移 正数右移高位补 ...

  7. Django之用户认证组件

    auth模块 之前我们在进行用户登录验证的时候,都是自己写代码,接收用户提交的数据,然后去数据库取数据进行匹配验证,其实Django已经给我们提供了内置的用户认证功能.不信的话你可以打开models. ...

  8. 修改xshell的默认字间距和行间距

    可能是不小心修改了xshell的某个配置,导致打开的会话中显示字间距和行间距都非常大,严重影响工作.参照官方手册也不能修改正常,详见:http://www.xshellcn.com/wenti/xiu ...

  9. XOR 加密

    XOR 是一个神奇的运算符, 观察它的真值表, 很容易得到以下结论: 假设现有 a , b 变量, 则 a ^ 0 == a a ^ 0xff == ~a (取反加1等于作为补码的a的真值的相反数的补 ...

  10. Newtonsoft.Json添加项

    JObject jo = (JObject)JsonConvert.DeserializeObject(result); ") { string domain=(jo["data& ...