Mysql权限管理grant命令使笔记


本文整理自网络,侵删。

MySQL 赋予用户权限命令的简单格式可概括为:

代码如下:
grant 权限 on 数据库对象 to 用户  [identified by '密码']

最常用的,弄主从同步的时候,给从库的slave用户设置拥有所有权限,权限all
仅允许其从192.168.0.2登录,并限定使用密码 funsion  (密码要用 单/双引号 括起来)

代码如下:
grant all on *.* to slave@192.168.0.2 identified by 'funsion';
执行完毕后,记得用 FLUSH PRIVILEGES;  刷新一下权限

一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。

代码如下:
grant select, insert, update, delete on testdb.* to common_user@'%'

二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数.....等权限。

代码如下:
grant create, alter, drop on testdb.* to developer@'192.168.0.%';

grant 操作 MySQL 外键权限。

代码如下:
grant references on testdb.* to developer@'192.168.0.%';
grant 操作 MySQL 索引权限。   
代码如下:
grant index on testdb.* to developer@'192.168.0.%';

给所有IP开放权限:

代码如下:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

grant 操作 MySQL 临时表权限。

代码如下:
grant create temporary tables 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.%';

执行完毕后,记得用 FLUSH PRIVILEGES;  刷新一下权限

三、grant 普通 DBA 管理某个 MySQL 数据库的权限。

代码如下:
grant all privileges on testdb to dba@'localhost'
其中,关键字 privileges 可以省略。

阅读剩余部分

相关阅读 >>

mysql导入导出.sql文件及常用命令小结

mysql中查询json格式的字段实例详解

详解mysql实现主从复制过程_mysql实例详解

mysql embedded程序启动成功实验

如何启动mysql服务

mysql怎么合并行

mysql用户管理相关知识介绍

mysql如何查看表名及注释

mysql大表查询慢怎么优化?

mysql子查询的使用详解上篇

更多相关阅读请进入《mysql》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...